SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

rjhe22
Posting Yak Master

233 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 
DECLARE
@SQLStmt NVARCHAR(MAX),
@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)

madhivanan
Premature Yak Congratulator

India
22744 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?

Madhivanan

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

rjhe22
Posting Yak Master

233 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

visakh16
Very Important crosS Applying yaK Herder

India
52309 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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000