May 19, 2008 at 4:58 am
Folks,
Is it possible to drop a table based on some criteria e.g.
drop table where......
Thanks
Mick
May 19, 2008 at 5:02 am
Hi
I would do it in the following manner:
if (select count (*) from Tablename) > 8
begin
drop table tablename
end
May 19, 2008 at 5:11 am
thanks Kevin,
So I guess it is not possible to apply conditionals directly to a drop statement then
May 19, 2008 at 7:22 am
[font="Verdana"]Yup, condition can not be placed on Drop statement.[/font]
MH-09-AM-8694
May 19, 2008 at 8:37 am
Thanks folks,
I got there in the end.
while EXISTS(SELECT * FROM sysobjects WHERE name like '%' + @table_Name + '%')
BEGIN
SELECT @found_name = [name] FROM sysobjects WHERE name like '%' + @table_Name + '%'
SET @sqlCommand = 'DROP TABLE ' + @found_name
EXEC (@sqlCommand)
END
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply