попробовать:
DECLARE @myvars uniqueidentifier --declare the local variable to store value in
SELECT @myvars=ID --assign's the ID column into the variable
FROM Device
WHERE DeviceID=@DeviceID
быстрый тест:
DECLARE @myvars uniqueidentifier --declare the local variable to store value in
declare @x table (id uniqueidentifier, valueOf varchar(4))
insert @x values (NEWID (),'aa')
insert @x values (NEWID (),'bb')
insert @x values (NEWID (),'cc')
SELECT @myvars=ID --assign's the ID column into the variable
FROM @x
WHERE valueOf='bb'
SELECT @myvars
select * from @x
ВЫХОД:
------------------------------------
36503FD9-A299-4DC5-A7BD-67605FF47ACE
(1 row(s) affected)
id valueOf
------------------------------------ -------
175DCBF8-C418-4B5B-9270-66C12980D489 aa
36503FD9-A299-4DC5-A7BD-67605FF47ACE bb
E4F075FF-BA4B-4BB5-AD9F-ADB03FE88590 cc
(3 row(s) affected)