Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update question

Author  Topic 

mhg1063
Starting Member

27 Posts

Posted - 2004-09-29 : 16:01:36
I have a table that has a few columns where we are doing some minor auditing. The table has a intial,current,previous column. Initial is when its first inserted to the table current & previous gets populated everyday. If I update previous with current, can I set current to null in the same update statement.

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-09-29 : 16:05:31
I believe your allowed to do that.
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-09-29 : 16:08:36
Yes You Can
[CODE]
CREATE TABLE #TEST(Initial INT, [Current] INT, Previous INT)
INSERT INTO #TEST
SELECT 1, 2, 3 UNION ALL
SELECT 4, 5, 6 UNION ALL
SELECT 7, 8, 9 UNION ALL
SELECT 10, 11, 12 UNION ALL
SELECT 13, 14, 15

SELECT * FROM #Test

UPDATE #TEST
SET Previous = [Current], [Current] = NULL

SELECT * FROM #Test

[/CODE]


Duane.
Go to Top of Page

mhg1063
Starting Member

27 Posts

Posted - 2004-09-29 : 16:28:11
Thanks ..
Go to Top of Page
   

- Advertisement -