471,599 Members | 1,285 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Batch Statments C# SQL Server 2000

I have used simple batch statments with C#.for example:
string select = "select model from cars where id = ?;select * from trucks
where model = ?";
where ? is a parameter whose value i have before running the bach statment.

I was wondering if it possible to use the value (model) retuned in the first
statement for the where clause in the second statment?

TIA,
Vinny
Nov 17 '05 #1
3 2426
Vinny,

You would have to use a different select statement to do this, like
this:

select * from trucks where model in (select model from cars where id = ?)

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vinny Vinn" <Vi*******@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
I have used simple batch statments with C#.for example:
string select = "select model from cars where id = ?;select * from trucks
where model = ?";
where ? is a parameter whose value i have before running the bach
statment.

I was wondering if it possible to use the value (model) retuned in the
first
statement for the where clause in the second statment?

TIA,
Vinny

Nov 17 '05 #2
what about...

select t.* from trucks t inner join cars c on t.model = c.model where c.id = ?

I don't know if there is a specific reason for using inline sql but I would
suggest using stored procedures.

"Vinny Vinn" wrote:
I have used simple batch statments with C#.for example:
string select = "select model from cars where id = ?;select * from trucks
where model = ?";
where ? is a parameter whose value i have before running the bach statment.

I was wondering if it possible to use the value (model) retuned in the first
statement for the where clause in the second statment?

TIA,
Vinny

Nov 17 '05 #3
what about...

select t.* from trucks t inner join cars c on t.model = c.model where c.id = ?

I don't know if there is a specific reason for using inline sql but I would
suggest using stored procedures.

"Vinny Vinn" wrote:
I have used simple batch statments with C#.for example:
string select = "select model from cars where id = ?;select * from trucks
where model = ?";
where ? is a parameter whose value i have before running the bach statment.

I was wondering if it possible to use the value (model) retuned in the first
statement for the where clause in the second statment?

TIA,
Vinny

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tyler Hudson | last post: by
3 posts views Thread by DBA | last post: by
12 posts views Thread by Selva Chinnasamy | last post: by
2 posts views Thread by XIAOLAOHU | last post: by

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.