May 12, 2006 at 5:43 am
Hi
Please can someone help.
I am creating an table using a variable name passed to an SP like:
exec ('CREATE TABLE "' +@TableName +'" (
[ID] [int] IDENTITY (1, 1) NOT NULL )')
How can i verify the existance of the @TableName table? I have tried the many variations of :
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[+ @TableName+]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
but I cannot seem to get the syntax right.
Thank you
Howard
May 12, 2006 at 6:52 am
IF OBJECT_ID(@TableName) IS NOT NULL AND OBJECTPROPERTY(OBJECT_ID(@TableName), N'IsUserTable') = 1
PRINT 'Table Exists'
ELSE
PRINT 'Table Does Not Exist'
Far away is close at hand in the images of elsewhere.
Anon.
May 12, 2006 at 10:16 am
Thank you, you made it look so easy and I was about to jump from the roof garden!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply