Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does insert return anything on MSSQL?

Status
Not open for further replies.

skurpyun

Programmer
Jun 19, 2002
60
US
Stupid question, but to be honest, this is the first time i've found myself needing to figure this out.
I am using asp to insert & update an MS Sql server table. The problem is as soon as it inserts new data, I need to query it again. Basically, all I want to know is, when using 'connection.execute(insert.....)', is anything returned?
Any help would be greatly appreciated. Thanks.

 
The insert statement will not return any records. The only ways to return records in the same round trip as the insert is through a stored procedure or sending multiple statements in one execute as follows:

Set rst = cnn.Execute("set nocount on;insert into t1 (col1, col2) values ('6','6');select * from t1 where col1='6';set nocount off;")

One of the drawbacks of this is you cannot use a disconnected recordset in this situation.

Is this what you were looking for?

Chris.
 
Perfect....that is exactly what I want. tried it and got the desired result. While the drawback is important to be aware of, for my purposes, it's not too significant a problem. Thank you very much. Wow these forums DO work!!

Thanks again, Chris.
-sk

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top