pgeisler
asked on
How do I pass a variable in a MSSQL linked server query?
Hello experts,
I would like to pass a variable in a linked server query. I am using MSSQL 2008 SQL server management studio.
I am querying a linked server running a Progress database
This query works
select count('order') as 'Orders Entered' from Openquery(V2, 'select order from oe_head where ord_date = ''12/28/2009'' and company_oe = ''cc'' and rec_type = ''o''')
I would like to pass a variable DATE for the ord_date but can't seem to get the syntax correct
Any ideas?
I would like to pass a variable in a linked server query. I am using MSSQL 2008 SQL server management studio.
I am querying a linked server running a Progress database
This query works
select count('order') as 'Orders Entered' from Openquery(V2, 'select order from oe_head where ord_date = ''12/28/2009'' and company_oe = ''cc'' and rec_type = ''o''')
I would like to pass a variable DATE for the ord_date but can't seem to get the syntax correct
Any ideas?
you can only do that with dynamic sql, as OPENQUERY does (unfortunately) not allow a variable for the SQL ...
ASKER
could you give an example?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect example, it was the quote "hell of quotes" I was having trouble with.