note 44868 deleted from function.mssql-execute by tomsommer

From: Date: Wed, 18 Aug 2004 19:33:10 +0000
Subject: note 44868 deleted from function.mssql-execute by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74916@lists.php.net to get a copy of this message
Note Submitter: tweir at woh dot rr dot com ---- Why does each connection support only one query at a time? In MS SQL 2000, you can sometimes get around this limitation by including the following statement at the top of a multi-pass query: SET NOCOUNT ON This turns off the “(x Rows Affected)” which is passed back every time you do a SELECT, UPDATE, or DELETE. For example, if you say: DECLARE @var datetime SELECT @var = (select max(invoicedate) from INVOICE_TABLE) SELECT * from INVOICE_TABLE where invoicedate = @var Your application would actually think there are two result sets – 1 for setting the variable, and one returning the invoice records – so it would actually generate an error prior to returning the invoice records. However if you say: SET NOCOUNT ON DECLARE @var datetime SELECT @var = (select max(invoicedate) from INVOICE_TABLE) SELECT * from INVOICE_TABLE where invoicedate = @var You will only have one result set passed back to the application - the invoice records you are really after. Setting a variable with a SELECT statement really does not give a result set, but returning the row count to the application makes the application think there is one. Trevor D. Weir DBA, CareSource mailto:tweir@woh.rr.com

« previous php.notes (#74916) next »