Quote | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Quote

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)[email protected]+char(34)+’)’) begin execute (‘DROP TABLE ‘+ @tmp)
execute (‘CREATE TABLE ‘[email protected]+’ ( 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 ‘[email protected]+’ ( tmp varchar(10) )’ )
else
execute (‘DROP TABLE ‘+ @tmp)
Madhivanan Failing to plan is Planning to fail
MANY THANKS, lubo
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)

]]>