Trouble understanding following sql
-
I'm reviewing the procs in http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=FileSpaceMon&referringTitle=Home, and have a couple question at the sql statement below: 1) where is the tempdb..sysobjects in sqlserver manager? I see a tempdb under the 'master' db...is that created by default? I don't understand why they have two periods (dot dot) in the tempdb..sysobjects. I do not see a sysobjects table within the tempdb. 2) Can someone explain the '#' in the LIKE '#FileSpaceStats%'. The % is the wildcard, but what is the leading # used for? IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE name LIKE '#FileSpaceStats%') BEGIN DROP TABLE #FileSpaceStats END Thanks
-
I'm reviewing the procs in http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=FileSpaceMon&referringTitle=Home, and have a couple question at the sql statement below: 1) where is the tempdb..sysobjects in sqlserver manager? I see a tempdb under the 'master' db...is that created by default? I don't understand why they have two periods (dot dot) in the tempdb..sysobjects. I do not see a sysobjects table within the tempdb. 2) Can someone explain the '#' in the LIKE '#FileSpaceStats%'. The % is the wildcard, but what is the leading # used for? IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE name LIKE '#FileSpaceStats%') BEGIN DROP TABLE #FileSpaceStats END Thanks
pzn3xq wrote:
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE name LIKE '#FileSpaceStats%') BEGIN DROP TABLE #FileSpaceStats END
# means a temporary table and such tables are stored in the
tempdb
. So the above query looks for a temp table starting withFileSpaceStats
and drops#FileSpaceStats
in case it exists. Hope that helps. Regards, Syed Mehroz AlamMy Blog My Articles Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. - Albert Einstein