dbTalk Databases Forums  

error in sql

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss error in sql in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SimplySuzy
 
Posts: n/a

Default error in sql - 10-05-2006 , 10:07 AM






Can someone please help me with this syntax error. the single and
double quotes always get me turned around.
I am trying to create a table with a dynamic name set by a global
variable in a dts package

here is me code

Declare @DB varchar(25)
set @DB = 'nfsntest1'
Declare @Tablename varchar(50)
set @TableName ='test'
Declare @sSQL varchar(8000)
set @sSQL = 'Create table ' + @DB + '.dbo.' + @TableName + '
([clmnt_idno] varchar (255) NULL )'
exec @sSQL

this is the error I get from DTS or query analyzer

Server: Msg 203, Level 16, State 2, Line 13
The name 'Create table nfsntest1.dbo.test ([c

it seems to be trying to find the sql statement instead of running it.
I can't place it in a stored procedure as it needs to be dynamic over
300 + databases

Any help is greatly appreciated.
Suzy


Reply With Quote
  #2  
Old   
SimplySuzy
 
Posts: n/a

Default Re: error in sql - 10-05-2006 , 10:15 AM






Never mind I figured it out

SimplySuzy wrote:
Quote:
Can someone please help me with this syntax error. the single and
double quotes always get me turned around.
I am trying to create a table with a dynamic name set by a global
variable in a dts package

here is me code

Declare @DB varchar(25)
set @DB = 'nfsntest1'
Declare @Tablename varchar(50)
set @TableName ='test'
Declare @sSQL varchar(8000)
set @sSQL = 'Create table ' + @DB + '.dbo.' + @TableName + '
([clmnt_idno] varchar (255) NULL )'
exec @sSQL

this is the error I get from DTS or query analyzer

Server: Msg 203, Level 16, State 2, Line 13
The name 'Create table nfsntest1.dbo.test ([c

it seems to be trying to find the sql statement instead of running it.
I can't place it in a stored procedure as it needs to be dynamic over
300 + databases

Any help is greatly appreciated.
Suzy


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.