Quantcast
Channel: t-SQl Scripts – WHERE BLOG = 'pdrsntsfrrr'
Browsing latest articles
Browse All 14 View Live

TempDB – Adding files and/or moving to another disk

USE master; GO /* How many tempdb data files should be created? http://www.sqlskills.com/blogs/paul/correctly-adding-data-files-tempdb/ */ SELECT CASE WHEN si.cpu_count 8 THEN N'Start with 8 tempdb...

View Article



My new template for Stored Procedure’s Header

/* ⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃⁃ [OBJECT NAME]: Object Name [DESCRIPTION]: Description [CODE BY]: Pedro Ferreira...

View Article

DBCC DROPCLEANBUFFERS and dirty pages

É comum que, durante a optimização de uma query, façamos a limpeza da cache do SQL Server para conseguirmos comprar resultados semelhantes. Para isso é normal serem utilizados os seguintes comandos:...

View Article

SQL Server Version

SET NOCOUNT ON; GO DECLARE @SQL_Version AS numeric(4,1); SELECT @SQL_Version = LEFT(CAST(SERVERPROPERTY('productversion') AS varchar), 4); SELECT CASE @SQL_Version WHEN 9 THEN '2005' WHEN 10 THEN...

View Article

Startup Times (Windows Server, SQL Server and DMV Stats)

É muitas vezes necessário saber quando é que o SQL Server foi reiniciado pela última vez e, se eventualmente, as estatísticas dos DMVs estão a acumular desde essa altura ou, por outro lado, se alguém...

View Article


Find invalid email addresses in SQL Server

My way to find invalid email addresses in a SQL Server table: ;WITH TrimEmail (Email) AS ( SELECT LTRIM(RTRIM(TWE.Email)) FROM TableWithEmail AS TWE WHERE TWE.Email IS NOT NULL ) SELECT Email FROM...

View Article

Delete all Stored Procedures

Depois de testar o .net membership, apercebi-me que foram criados vários stored procedures. E agora como apaga-los todos de uma vez? Atenção que este script apaga todos os stored procedures de uma...

View Article

Converter ntext em nvarchar(max)

SELECT o.name AS table_name, c.name AS column_name, ( 'alter table [' + o.name + '] ' + 'alter column [' + c.name +'] ' + case when c.system_type_id = TYPE_ID('text') then 'varchar(max)' else...

View Article


Grant user permissions to create jobs in SQL Server

USE msdb; GO CREATE USER 'NewUser' FOR LOGIN 'ExistingLogin'; GO EXEC sp_addrolemember 'SQLAgentUserRole', 'NewUser'; GO

View Article


Find duplicated values on a table

With the next t-SQL statement you can find duplicate values in any table, just change the fields into the columns you want to search and change the table into the name of the table you need to search....

View Article
Browsing latest articles
Browse All 14 View Live


Latest Images