SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


store the select query result as variable and load on another table in ssis


store the select query result as variable and load on another table in ssis

Author
Message
logicinside22
logicinside22
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1900 Visits: 1419
Hi guys ...

Like to know how i can store select query result in variable and then load it to the other table in SSIS-2005.

i am using select count (*) from dbo.my_Table on Server1. want to store this query result in variable and then load this result on Server2\MY_db.dbo.xyz.



Thanks for help

Aim to inspire rather than to teach.
SQL Server DBA
Sean Lange
Sean Lange
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60218 Visits: 17952
logicinside22 (4/19/2013)
Hi guys ...

Like to know how i can store select query result in variable and then load it to the other table in SSIS-2005.

i am using select count (*) from dbo.my_Table on Server1. want to store this query result in variable and then load this result on Server2\MY_db.dbo.xyz.



Thanks for help


Why not just insert it directly instead of messing around with variables?


insert Server2.MY_db.dbo.xyz
select COUNT(*)
from Server1.MY_db.dbo.my_Table



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
logicinside22
logicinside22
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1900 Visits: 1419
Hi sean ,
that's what i am doing now. but when this packaged goes in diff environment every time we have to change the server name here .so don't want to keep hard coded value in package.

Aim to inspire rather than to teach.
SQL Server DBA
Vikash Kumar Singh
Vikash Kumar Singh
SSC Veteran
SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)

Group: General Forum Members
Points: 214 Visits: 243
You can follow the following steps to get the column values in a variable.

1. Create a package level variable(ex: varCount)

2. Create an Execute SQL Task and set following attributes in the Editor box
ResultSet=Single row and ByPassPrepare=False

3. In the Editor box of Execute SQL Task you can go to ResultSet and putt ResultName=0 and VariableName you can select as varCount.

This way your variable will be populated with the value and you can insert this variable value in a another table.

Vikash Kumar Singh || www.singhvikash.in
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)

Group: General Forum Members
Points: 37834 Visits: 14411
How to: Map Result Sets to Variables in an Execute SQL Task - SQL Server 2005

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search