|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:48 PM
Points: 41,
Visits: 175
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 12:32 PM
Points: 180,
Visits: 628
|
|
| Great article. I was just about to send a very similar article for submission. Guess you beat me to it:)
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Sunday, May 22, 2011 6:15 PM
Points: 65,
Visits: 80
|
|
I second that. The for each loops are a great tool. I use one with variables and script for looping through database backups on my main server to grab the latest dated ones and FTP them over to a secondary backup server (no I'm not really paranoid about losing data!)
Best Regards Terry
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, February 26, 2008 3:18 AM
Points: 2,
Visits: 6
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, January 13, 2013 10:55 AM
Points: 166,
Visits: 417
|
|
Just came across your article and fine it very useful tools for me to learn sqlis. I have a problem with Execute SQL Task in the loop container: Insert into tmpTlogFileList(FileName)values(@FileName): Execute SQL Task: Executing the query "insert into tmpTlogFileList (FileName) values (@FileName)" failed with the following error: "Must declare the scalar variable "@FileName".".
Must I declare @Filename as nvarchar(128) from the sql statement?
thanks
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:48 PM
Points: 41,
Visits: 175
|
|
Right-click your "Execute SQL Task". In the "Execute SQL Task Editor", go to Parameter Mapping. Add a parameter as follows:
Variable Name - User::varTLogFileName Direction - Input Data Type - String Parameter Name - @FileName Parameter Size: -1
Hope this is now clear. Best of luck!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, January 13, 2013 10:55 AM
Points: 166,
Visits: 417
|
|
Paul,
I get the same error...Here are a bit more detail on execute sql task: General tab: resultset: None connectionType: OLE DB connection: UserServerConnection sqlsourceType: Direct input sqlstatement: insert into tmpTLogFileList(FileName) values (@FileName) bypassPrepare: True
The Parameter Mapping is same above as you mention, except for Data Type - Nvarchar, I can't fine the dropdown for String.
I appreciate all you help thanks....
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "insert into tmpTLogFileList(FileName) values (@FileName)" failed with the following error: "Must declare the scalar variable "@FileName".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. Task failed: Execute SQL Task
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Sunday, May 22, 2011 6:15 PM
Points: 65,
Visits: 80
|
|
tran008,
I think you need to provide a bit more basic information about what you are trying to do. Where are you getting the @FileName parameter from anyway? My thoughts are that it should be declared as a User::[varname] in the for each loop and then this mapped across to the parameter in the SQL Task, but without knowing what it is you are trying to do it is hard to be of more assistance.
Best Regards Terry
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Sunday, May 22, 2011 6:15 PM
Points: 65,
Visits: 80
|
|
As an after thought - depending on what you wish to do of course, you may have to execute the sql statement as a variable. Out of curiosity I just put together a for each loop to save a series of .txt files into a table and this worked well by using a variable for the sql statement. Let me know if you want any further detail on this method.
Best Regards Terry
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, January 13, 2013 10:55 AM
Points: 166,
Visits: 417
|
|
thanks...I finally figure this out after long search.
OleDB...connection.
INSERT INTO tempTlogFileList (FileName) VALUES (?)
instead of INSERT INTO tempTlogFileList (FileName) VALUES (@FileName)
|
|
|
|