Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

store the select query result as variable and load on another table in ssis Expand / Collapse
Author
Message
Posted Friday, April 19, 2013 2:06 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:13 PM
Points: 321, Visits: 1,285
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
Post #1444598
Posted Friday, April 19, 2013 2:20 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 12,995, Visits: 12,414
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 Moden's 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)
Post #1444603
Posted Friday, April 19, 2013 8:15 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:13 PM
Points: 321, Visits: 1,285
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
Post #1444665
Posted Sunday, April 21, 2013 1:02 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, June 9, 2014 6:15 AM
Points: 79, 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
Post #1444814
Posted Friday, April 26, 2013 10:10 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:33 AM
Points: 7,107, Visits: 12,660
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
Post #1447083
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse