SQL Server Performance


Discussion in 'T-SQL Performance Tuning for Developers' started by luma, Jun 17, 2005.

  1. luma New Member

    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)+')')


    execute ('DROP TABLE '+ @tmp)
    execute ('CREATE TABLE '+@tmp+' ( tmp varchar )' )

    Server: Msg 170, Level 15, State 1, Line 9
    Line 9: Incorrect syntax near 'char'.


    Thanks, Lubo
  2. Madhivanan Moderator

    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) )' )
    execute ('DROP TABLE '+ @tmp)


    Failing to plan is Planning to fail
  3. luma New Member

    MANY THANKS, lubo
  4. FrankKalis Moderator

Share This Page