473,406 Members | 2,369 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,406 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 2486
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tyler Hudson | last post by:
After reading Erland Sommarskog's most enlightening articles on SQL Server 2000's error handling capabilities (http://www.sommarskog.se/error-handling-I.html and...
3
by: DBA | last post by:
I have a windows batch file that executes a SQL Server bcp command. I would like to obtain a return code if the bcp command fails. However, I cannot seem to find the return code (if any) for bcp....
0
by: Steve Jorgensen | last post by:
I remember that I used to set up utility batch files, and create Windows shortcuts to them that would ask the user for parameters to supply to the batch files. From what I can tell, this...
0
by: Leo Heska | last post by:
Hi I haven't seen the following problem mentioned anywhere We have an application written in VB.NET which executes a batch file (named startJob.cmd). We have discovered that if that batch file...
12
by: Selva Chinnasamy | last post by:
Hi I am using batch commands against Ms-Access and getting an error Message "Characters found after end of SQL statement." String Here is my sql Dim str_screens As String = "Select * from Screens...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
0
by: ee_stevek | last post by:
hi guys, here is my problem: i have to maintain a web vb.net application developped some times ago. The application was developped on Windows2000 SP3 with Visual Studio 2003 (7.1). and the...
2
by: raghutumma | last post by:
Hi, How can we execute SQL Scripts using Batch file??? i think Batch file should contain Username,Password,Database and Scripts... Using that file scripts should run... How can i give...
3
by: John | last post by:
Hi. I have a number of batch jobs that are ran nightly on our Windows 2000 based Oracle 8.1.7 (soon to be 9i) server. I have these designed just right, so the Windows Scheduled Tasks runs them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.