NathanGriffiths
Programmer
I have traditionally tested for the existence of objects such as tables using the IF EXISTS syntax and information_schema e.g.
But I think this might be a simpler way;
Any comments?
thanks,
Nathan
![[yinyang] [yinyang] [yinyang]](/data/assets/smilies/yinyang.gif)
----------------------------------------
Want to get a good response to your question? Read this FAQ! -> faq183-874
----------------------------------------
Code:
IF EXISTS(SELECT 1 FROM Information_Schema.Tables WHERE Table_Name = 'MyTable')
BEGIN
...
END
But I think this might be a simpler way;
Code:
IF Object_ID('MyTable') IS NOT NULL
BEGIN
...
END
Any comments?
thanks,
Nathan
![[yinyang] [yinyang] [yinyang]](/data/assets/smilies/yinyang.gif)
----------------------------------------
Want to get a good response to your question? Read this FAQ! -> faq183-874
----------------------------------------