The same as the one-way, to solve more than one line of T-SQL to return results is a good habit. In T-SQL local variable, use the record set of results returned, if it will cover up with a SELECT clause, the potential problems.
If the code only hope to get a value, SELECT clause will be assigned a value, despite the fact that may return multiple values. If this allocation error occurs with the SET command. However, when you want a single value of the record, with the SET command makes T-SQL code more robust.
The following script demonstrates this:
CREATE TABLE SetTest
(Pkey INT NOT NULL
CONSTRAINT pk_SetTest primary key,
Name VARCHAR (30) NOT NULL
CONSTRAINT df_col1 DEFAULT 1
INSERT SetTest VALUES (1,''Mary Johnson'')
INSERT SetTest VALUES (2,''John Highland'')
INSERT SetTest VALUES (3,''Ashly Robertson'')
INSERT SetTest VALUES (4,''Mary Johnson'')
DECLARE @ myVar INT
SELECT @ myVar = Pkey FROM SetTest WHERE Name =''Mary Johnson''
DECLARE @ myVar INT - ERROR WILL BE GENERATED
SET @ myVar = (SELECT Pkey FROM SetTest WHERE Name =''Mary Johnson'')
DROP TABLE SetTest
OGM to MP4
Ntoskrnl.exe Missing How To Repair These Pc
AVI TO DivX
3GP to MPEG