February 1, 2011 at 11:57 pm
Whats the output for following code
IF EXISTS (
SELECT *
FROM dbo.sysobjects
WHERE 1=1
AND id = object_id(N'dbo.xxx')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.xxx
February 2, 2011 at 12:05 am
What do you get when you run this code?
February 2, 2011 at 12:08 am
not at i executed this code.But which purpose these object propety and sysobjects are using in this code i am not getting
February 2, 2011 at 12:17 am
Okay, what do you think the code is trying do?
February 2, 2011 at 12:21 am
its a sql script for Droping the table from the database,if the condition success then the table would be dropped.But i am not getting the condition.
February 2, 2011 at 4:31 am
IF EXISTS (
SELECT *
FROM dbo.sysobjects
WHERE 1=1
AND id = object_id(N'dbo.xxx')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.xxx
the condition 1=1 is redundent as it is always true.
id = object_id(N'dbo.xxx') matches the object id
OBJECTPROPERTY checks that it should be a user defined table
u can get it all from google ot BOL
Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply