473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

OpenQuery and passing variables

Anyone,

Is this possible?

I am connecting to a TeraData server via MS SQL 8.0 using the OpenQuery
statement. I need to pass a list of ever-changing deal numbers My
list of numbers are stored as a table on MS SQL.

So what I want is this

Select * from OpenQuery(TeraSrvr, "
Select Col1
, Col2
, Col3
From Teradata_Table_1

Where Deal_no in (Select Deal_no from SQLTable)
")

Now I know that wont work, but How can I pass 184 Deal Numbers from my
SQL server to this query before it is sent to the Teradata server to be
done? Do I have to keep re-doing an in statement each month?

Anyone can help?

Doug

Jul 23 '05 #1
3 13239
(do**********@hotmail.com) writes:
So what I want is this

Select * from OpenQuery(TeraSrvr, "
Select Col1
, Col2
, Col3
From Teradata_Table_1

Where Deal_no in (Select Deal_no from SQLTable)
")

Now I know that wont work, but How can I pass 184 Deal Numbers from my
SQL server to this query before it is sent to the Teradata server to be
done? Do I have to keep re-doing an in statement each month?


To do it with OPENQUERY you would have to use dynamic SQL to build
the SQL statement, and also to execute the OPENQUERY thing, as
OPENQUERY does not take parameters of any kind of whatsoever.

But cannot you not use a linked server instead:

SELECT t.*
FROM TeraSrvr.db.catalog.Teradata_Table_1 t
WHERE t.Deal_no in (Select s´.Deal_no from SQLTable s)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
Thanks for this, I will chekc on the link bit below. Can you help me
with how to do this in Dynamic SQL. I can't find how to get a list of
my numbers into a Var so I can pass them on and use them in the
openquery statement.

Thanks again

Doug

Erland Sommarskog wrote:
(do**********@hotmail.com) writes:
So what I want is this

Select * from OpenQuery(TeraSrvr, "
Select Col1
, Col2
, Col3
From Teradata_Table_1

Where Deal_no in (Select Deal_no from SQLTable)
")

Now I know that wont work, but How can I pass 184 Deal Numbers from my
SQL server to this query before it is sent to the Teradata server to be
done? Do I have to keep re-doing an in statement each month?


To do it with OPENQUERY you would have to use dynamic SQL to build
the SQL statement, and also to execute the OPENQUERY thing, as
OPENQUERY does not take parameters of any kind of whatsoever.

But cannot you not use a linked server instead:

SELECT t.*
FROM TeraSrvr.db.catalog.Teradata_Table_1 t
WHERE t.Deal_no in (Select s´.Deal_no from SQLTable s)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Jul 23 '05 #3
(do**********@hotmail.com) writes:
Thanks for this, I will chekc on the link bit below. Can you help me
with how to do this in Dynamic SQL. I can't find how to get a list of
my numbers into a Var so I can pass them on and use them in the
openquery statement.


Alas, in SQL 2000 the only safe way is to run a loop over the table.
There are some shortcuts, but they unrely undefined behaviour, so I
advise against such use.

For dynamic SQL in general, I have a longer article on the topic on
my web site: http://www.sommarskog.se/dynamic_sql.html.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: lawrence | last post by:
Those of you with backgrounds with the C language will laugh at my mistake, but those of you, like myself, who deal mostly with PHP should be warned about passing variables as references -...
7
by: Matthew Robinson | last post by:
i read a tutorial the other day on passing variables between php pages using a html form and setting the action to the php page to parse, can anybody see anything wrong with the code below? the...
2
by: Chieko Kuroda | last post by:
Hello all, I would like to learn the syntax for passing variables that I retreived from a database to a second asp page. Currently, I'm using: Response.Write "<tr><td>&nbsp;</td><td><Font size=...
1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
7
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
3
by: jsdeveloper | last post by:
Hi, I just started programming in javascript, and I'm having a problem passing variables between javascript and asp code in .asp page. Can you please help? I've given the sample code below. ...
1
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
5
by: Shawn Northrop | last post by:
test.php: <?php $d=$_GET; echo $d; ?> when i go to www....com/test.php?data=1 nothing happens.
6
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
6
BezerkRogue
by: BezerkRogue | last post by:
This is the most fundamental action I am sure, but I can't seem to make it happen. I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.