Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Joining queries between servers or use variables?

Author  Topic 

msdevcoder
Starting Member

4 Posts

Posted - 2009-04-24 : 10:43:32
Hi

I am newbie to SSIS 2005.
I need to pull info from two different sql servers, but not linked. (cant do that).
For eg:
I need to concatenate a single categoryId (like 101) from server1.db1.table1 to the productIds from server2.db1.table1.
Like select categoryid from server1.db1.table1.categories where categoryname = 'Apparels'
Then select categoryid + cast(productid as varchar(5)) as productuniqueid from Server2.db1.table1.products.

1. I dont know if i can join queries between sql servers which is not linked.
2. I tried storing the categoryid in a package variable. But dont know how to use that variable in select clause in sql command of oledb source editor.
like select + '[user::categoryd]' + cast(productid as varchar(5)) as productuniqueid from Server2.db1.table1.products ???

Thanks
Venky

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-24 : 11:00:00
If you have already stored the value in the variable, you can use OLE Db command to do the next select.

Check this. it explains how it needs to be done.

http://technet.microsoft.com/en-us/library/ms141773.aspx
Go to Top of Page

msdevcoder
Starting Member

4 Posts

Posted - 2009-04-24 : 12:35:44
I tried to use
declare @catID as varchar(5)
set @catID = ?
SELECT distinct @catID + cast(productid as varchar) as ProductId FROM products
but it throws syntax error. it didnt throw any error if i put that ? in a where clause.
or
Can we assign the user variable like this?
for eg:
set @catID = @[user::CategoryId]
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-24 : 14:36:44
Shouldn't it be just

SELECT ? + cast(productid as varchar) as ProductId FROM products
WHERE productid = ?
Go to Top of Page
   

- Advertisement -