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)
 need to populate row by row using cursor or while

Author  Topic 

sachingovekar
Posting Yak Master

101 Posts

Posted - 2011-04-28 : 11:06:42
Hi,

create table dbo.sach
(region varchar(100),name varchar(100)
)

insert into dbo.sach values('argentina','adobe')
insert into dbo.sach values(null,'aftr')
insert into dbo.sach values(null,'ie')
insert into dbo.sach values('india','adobe')
insert into dbo.sach values(null,'ftey')
insert into dbo.sach values(null,'dfgh')
insert into dbo.sach values('usa','adobe')

select * from dbo.sach

I want to update null with region above it.
for eg for argentina I will have first 3 rows
How will i acheive this result. I have hige data in one table.

Please help
sachin

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-28 : 11:20:04
You need something to order the rows by.
How do you know the rows need to be updated in this order.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sachingovekar
Posting Yak Master

101 Posts

Posted - 2011-04-28 : 11:32:27
do you have any solution to it. this is just a scenario.. and the rows order is the same shown in query.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-04-28 : 11:43:35
Here we go! What guarantees the order in your table? There has to be something that says "this one comes before that one", like an identity field

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -