USE pubs
GO
DECLARE @cost money
SELECT @cost = price FROM titles 
  WHERE title_id = 'bu1032'
SET context_info @cost
GO
SELECT convert(money, substring(context_info, 1, 8))
FROM master..sysprocesses
WHERE spid = @@spid
GO
SELECT convert(money, context_info)
FROM master..sysprocesses
WHERE spid = @@spid
GO
DECLARE @cost money, @context binary(128)
SELECT @cost = price FROM titles 
  WHERE title_id = 'ps2091'
SELECT @context = convert(binary(8),context_info) + convert(binary(8), @cost)
FROM master..sysprocesses
WHERE spid = @@spid 
SET context_info @context
GO
SELECT First_price = convert(money, substring(context_info, 1, 8))
FROM master..sysprocesses
WHERE spid = @@spid
GO
SELECT Second_price = convert(money, substring(context_info, 9, 8))
FROM master..sysprocesses
WHERE spid = @@spid
Published in: SQL
Download

Related snippets