Tuesday 1 March 2011

SQL Temp Tables

Had a coliation issue trying to create a temp table on a database. It worked for 2005, 2000 64bit, but not for one 2000database. Create this sort of temp table produced a coliation issue will trying a select using the temp table.


DECLARE @Temp TABLE (Item varchar(50))


However when using


CREATE TABLE #Temp (Item varchar(50))


this worked fine. Rather odd error as the two lines do exactly the same. The first one will create the table in memory and the second will create it on disk. SQL server will overrule either command and do what it thinks best and create in memory or disk regardless to your wishes. The first for small table should be quicker.

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.