Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 declare table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

283 Posts

Posted - 11/05/2013 :  06:10:43  Show Profile  Reply with Quote
hi need to test info from a table to see if my query is wqorking right. trying to test a bit of a time. trying the below code first but keep getting Must declare the table variable "@WorkingNamingTable".
i have declared it so not sure why it wont work. any ideas anyone

-- Declare varibles 
@FieldName NVARCHAR(50),
@StringReplacement NVARCHAR(200),
@StringToFind NVARCHAR(200),
@maxPK INT,
@pk INT,
@Quote NVARCHAR(1),
@WorkingNamingTable NVARCHAR(256),
@WorkingDataloadFile2 NVARCHAR(256)
 --@WorkingNamingTable = 'WorkingNamingTable'
--SELECT @WorkingDataloadFile2 = 'WorkingDataloadFile2'

SELECT @FieldName = Field from @WorkingNamingTable WHERE PK_ID = (Select PK_ID From #StringReplace Where PK_ID = @pk)

Premature Yak Congratulator

22864 Posts

Posted - 11/05/2013 :  06:20:57  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
You need to use Dynamic SQL. But why are you doing this?


Failing to plan is Planning to fail
Go to Top of Page

Constraint Violating Yak Guru

283 Posts

Posted - 11/05/2013 :  06:23:59  Show Profile  Reply with Quote
i have a query that im using in ssis and im getting an error and i cant figure out why it wont work im just trying to figure out why it wont work. it should works for another person in a different package thats does the same thing but wont work for me
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 11/05/2013 :  08:19:53  Show Profile  Reply with Quote
Wherever you use the above query wont work as its not syntactically correct.

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000