What does ‘COLLATE SQL_Latin1_General_CP1_CI_AS’ do?

It sets how the database server sorts (compares pieces of text). in this case: SQL_Latin1_General_CP1_CI_AS breaks up into interesting parts: latin1 makes the server treat strings using charset latin 1, basically ascii CP1 stands for Code Page 1252 CI case insensitive comparisons so ‘ABC’ would equal ‘abc’ AS accent sensitive, so ‘ΓΌ’ does not equal … Read more

How can I clear the SQL Server query cache?

Here is some good explaination. check out it. http://www.mssqltips.com/tip.asp?tip=1360 CHECKPOINT; GO DBCC DROPCLEANBUFFERS; GO From the linked article: If all of the performance testing is conducted in SQL Server the best approach may be to issue a CHECKPOINT and then issue the DBCC DROPCLEANBUFFERS command. Although the CHECKPOINT process is an automatic internal system process … Read more

SQL Server split CSV into multiple rows

from #client_profile_temp cpt cross apply dbo.split( #client_profile_temp.interests, ‘,’) as split <–Error is on this line I think the explicit naming of #client_profile_temp after you gave it an alias is a problem, try making that last line: cpt.interests, ‘,’) as split <–Error is on this line EDIT You say I made this change and it didn’t … Read more

CAST and IsNumeric

IsNumeric returns 1 if the varchar value can be converted to ANY number type. This includes int, bigint, decimal, numeric, real & float. Scientific notation could be causing you a problem. For example: Declare @Temp Table(Data VarChar(20)) Insert Into @Temp Values(NULL) Insert Into @Temp Values(‘1’) Insert Into @Temp Values(‘1e4’) Insert Into @Temp Values(‘Not a number’) … Read more

How to run the same query on all the databases on an instance?

Try this one – SET NOCOUNT ON; IF OBJECT_ID (N’tempdb.dbo.#temp’) IS NOT NULL DROP TABLE #temp CREATE TABLE #temp ( [COUNT] INT , DB VARCHAR(50) ) DECLARE @TableName NVARCHAR(50) SELECT @TableName=”[dbo].[CUSTOMERS]” DECLARE @SQL NVARCHAR(MAX) SELECT @SQL = STUFF(( SELECT CHAR(13) + ‘SELECT ‘ + QUOTENAME(name, ””) + ‘, COUNT(1) FROM ‘ + QUOTENAME(name) + ‘.’ … Read more