Adi Cohn-120898 (7/8/2013)
Hi allPleas check out the code bellow:
declare @tbl table (i int)
declare @i int
insert into @tbl (i) values (1)
update @tbl
set @i = i, i = 2
select @i as varible, i from @tbl
This code stores the column's old value in a variable and then modifies the column's value. I know that code like that has been working for years, but I don't know if it is something that could be modified in the future. If an application has this kind of code, could it break with the next service pack or next SQL Server version or is this kind of code something that should always work?
Adi
It sounds like you're scoping out a project, Adi. What do you actually need this for? I ask because what you've posted makes up the "guts" of what has become endearingly known as the "Quirky Update" which, BTW, can also take the form of SET @variable = column = expression when used with some care.
--Jeff Moden
Change is inevitable... Change for the better is not.