Haloo , help me please. i don't know, where i'm doing a mistake DECLARE @tmp as varchar(255), set @tmp='aaa' print @tmp execute ('IF OBJECT_ID ('+char(34)+@tmp+char(34)+')') begin execute ('DROP TABLE '+ @tmp) execute ('CREATE TABLE '+@tmp+' ( tmp varchar )' ) end ** Server: Msg 170, Level 15, State 1, Line 9 Line 9: Incorrect syntax near 'char'. ** Thanks, Lubo
This is what you have to do DECLARE @tmp as varchar(255) set @tmp='aaa' IF OBJECT_ID(@tmp) is null execute ('CREATE TABLE '+@tmp+' ( tmp varchar(10) )' ) else execute ('DROP TABLE '+ @tmp) Madhivanan Failing to plan is Planning to fail
See my reply in your other thread. Sometimes QUOTENAME comes in handy in such situations. -- Frank Kalis Microsoft SQL Server MVP http://www.insidesql.de Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)