by pietman
27. August 2009 21:41
Capturing Errors and Rowcount at once (only avail for one SQL command - therefore grab both at once)
SELECT * FROM customer
SELECT @RowCount = @@ROWCOUNT, @Error = @@ERROR
Declaring vars:
DECLARE @j varchar(10)
Casting:
CAST(@@ROWCOUNT AS varchar(12))
Temp tables:
CREATE TABLE #Temp (i int, j varchar(10))
INSERT INTO #Temp (i, j) VALUES (1, 'First Row')
INSERT INTO #Temp (i, j) VALUES (1, 'Second Row')
GO
other interresting examples:
select n as [Matched state], a as Episodes , b as Isolates from
(
SELECT 'Matched' as n, 1024 as a, 1024 as b
union SELECT 'Partially' , 12 ,12
union SELECT'No Match' as n , 33 as a ,27 as b
) as t
8ce79c92-6c96-4fff-902b-4b9984c3d0ab|0|.0
Tags:
SQL SERVER