Reputation: 143
I have 2 Dataset queries and a parameter called 'database'
If the value for 'database' is 'abc', it should use the statement below
select * from abc.item
Meanwhile, if the value for 'database' is 'cba', it should use this statement
select * from cba.item
Initially, I tried passing in the parameter like this
select * from ?.item
Of course, that didn't work.
I am using ODBC connection to an iSeries
Upvotes: 1
Views: 1695
Reputation: 1541
you can also create a common data set for both by writing an expression for connection String
Refer to url http://www.sqlservercurry.com/2011/06/dynamic-connection-string-in-sql-server.html
Upvotes: 0
Reputation: 1620
I assume that the returned columns are the same for abc and cba?
You have to dynamically build your query:
declare @param as varchar(25)
declare @sql as varchar(2000)
set @param = 'abc'
set @sql = 'select * from ' + @param + '.item'
exec (@sql)
Upvotes: 1