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.
Author |
Topic |
gpreece
Starting Member
1 Post |
Posted - 2006-11-29 : 21:17:26
|
Hi all,I'm trying to write a query that will update a table field;select c1, c2, case when c3 is null then (update t2 set c4 = c4+1)else c3 from t1c4 is a bigint column that is seeded at 10000000 and I want to increment this field by 1 each time a null value is found in the t1 table.Is this possible?I'm trying to create a sequential number for each column where c3 is null.Gary Preece |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-11-30 : 00:05:56
|
you can't use case that way.how about simply this:update t2 set c4 = c4 + (select count(*) from t1 where c3 is null)note that you didn't specify a where clause for your update, so this will update ALL ROWS in t2. SqlSpec: a fast and comprehensive data dictionary generator for SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003 http://www.elsasoft.org |
 |
|
|
|
|