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 2000 Forums
 SQL Server Development (2000)
 pass thr queries

Author  Topic 

sach
Starting Member

4 Posts

Posted - 2002-08-22 : 08:39:12
where can i find more info about the syntax of pass thru query apart from BOL Online. I am after the syntax which shows how to insert and update data into tables using pass thru query.


Thanks

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-08-22 : 09:21:23
Look up OPENQUERY in BOL

Go to Top of Page

sach
Starting Member

4 Posts

Posted - 2002-08-22 : 09:42:08
what is wrong with this stored procedure?

CREATE PROCEDURE up @u varchar (50) AS

select * FROM OPENQUERY (ORAS, 'Select * into reflink from IBA.ACUTE_OUTRF1AF WHERE OTRLURNO='' @u''')


this doesn't seem to work.
Thanks

Go to Top of Page

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2002-08-22 : 10:02:22
as far as I know the select * into won't return any records and probably is not a good idea ... try removing the into reflink

Go to Top of Page

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-08-22 : 11:16:59
You need to separate the sql steps from the oracle steps. Here's the way to do it:

 
DECLARE @oracleptlistqueryworking NVarChar(4000)
SET @oracleptlistqueryworking = N'INSERT INTO #TBL_PATIENT_LIST_WORKING (PATIENT_CDR_ID)

SELECT PATIENT_CDR_ID FROM OPENQUERY(CDRQ3, ''SELECT PATIENT_CDR_ID FROM CDR.PATIENT_INPATIENT_CURRENT_CPI WHERE
PATIENT_SERVICE IN ' + @medsvc + ' OR LOCN_CODE IN ' + @locid + ''')'

exec sp_executesql @oracleptlistqueryworking


The #TBL_PATIENT_LIST_WORKING is on the SQL side as well as the variables @medsvc and @locid.



Go to Top of Page

sach
Starting Member

4 Posts

Posted - 2002-08-23 : 04:17:21
this query looks complicated to me also i would like to create a new table using 'select into' in my database. this stored procedure creates the table each time with the unique id entered as the input parameter.

Go to Top of Page
   

- Advertisement -