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 2005 Forums
 Transact-SQL (2005)
 Update a Table

Author  Topic 

Sudha1234567
Starting Member

5 Posts

Posted - 2009-08-31 : 09:54:41
I has to update the table temp as below
ID NAME
1 System1
2 System2
3 System3
4 NULL
5 NULL
6 System5
7 System6

The ID 4 Name has to be Updated wih the Next greatest Value which has Name NOT NULL

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-08-31 : 09:57:09
update table
set name = 'system'+right(name,1)+1
where id = 4

or

update table
set name = 'system'+cast(id as varchar(32))
where name is null
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-31 : 10:25:12
declare @id int
select @id = max(id) from tablename
select 'system' + cast( @id as varchar(32))
Go to Top of Page
   

- Advertisement -