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
 Transact-SQL (2005)
 cursor with openquery

Author  Topic 

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-22 : 01:36:42
Hi,

I had open cursor for a select query with openquery.
I want to use bind variable in that openquery.
for Ex:
DECLARE CBANK CURSOR FOR
SELECT
P_name
FROM OPENQUERY([CMS10], 'SELECT p_name
FROM PARTY WHERE P_CODE = ''001155'' )
WHERE P_CODE = @UCC
OPEN CBANK...................

This is working fine, but i want to put bind variable in place of hard coding the party code as '001155'


what to do please?

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-22 : 01:50:50
Hi,
I belive that,had Answered this question some days before to you.
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-22 : 01:55:26
look at this thread.
http://www.sommarskog.se/dynamic_sql.html#OPENQUERY
Go to Top of Page

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-22 : 04:55:15
quote:
Originally posted by haroon2k9

Hi,
I belive that,had Answered this question some days before to you.




ya, but this query is in cursor, if i do the same i am getting error.

thanks
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-22 : 05:08:11
quote:
Originally posted by asuni

quote:
Originally posted by haroon2k9

Hi,
I belive that,had Answered this question some days before to you.




ya, but this query is in cursor, if i do the same i am getting error.

thanks



Have you looked at this thread i mentinoned above..
Go to Top of Page
   

- Advertisement -