My Technical Notes

Thursday, 31 January 2013

Assigning two variables in a SELECT Statement

To assign two variables in one go using SQL in a select statement we can do something like:


DECLARE @forename NVARCHAR(50);
DECLARE @surname NVARCHAR(50);
SELECT TOP 1 @forename = Forename, @surname = Surname FROM dbo.Persons

No comments: