Checking for Existence of a Table

Last Post 07 Apr 2002 06:38 AM by DocX. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
New Member
New Member

07 Apr 2002 06:38 AM
If you do a Generate SQL task on a table and include (by default) the DROP TABLE option, you get code that looks like this:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablename]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tablename]

I know this is a STUPID question but what is the 'N' in the N'[dbo].[tablename] and N'IsUserTable' sections? And is this the best way to go about this? I often have to check for the existence of a table - seems there should be a function built in for it. Would this be a good place to build a UDF?



Acceptable Use Policy