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
SSC Eights!
SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)

Group: General Forum Members
Points: 814 Visits: 1403
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
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26319 Visits: 17553
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
SSC Eights!
SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)SSC Eights! (814 reputation)

Group: General Forum Members
Points: 814 Visits: 1403
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-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 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
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15037 Visits: 14396
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