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 |
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2002-03-15 : 12:21:48
|
| We have two tables from two databases.One table has state abbreviation in it but stateid column is null.I need to get the stateid for that abbreviation and fill my first table.Second table is state table which has id and abbreviation both.First table has id column too.The table update only one row(last one that has id=3).After 3 the loop is breaking.If i do 'Select @id,@StateID,@State'I get all three records.Any Suggestion would be appreciated.Declare @id intDeclare @State nvarchar(10)Declare @StateId int Set @id=1While @id <= (select Max(id) from tblImplementSchedule)Begin Set @State=(select state from tblImplementSchedule where id=@id) Set @StateId=(select StateID from hhtbusinessCenter.dbo.smlstate where hhtbusinessCenter.dbo.smlstate.abbreviation=(Select @State)) Update tblImplementSchedule Set StateID=(Select @StateID) --Select @id,@StateID,@State Set @id=@id+1 If @id =4 BreakEnd |
|
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2002-03-15 : 12:34:24
|
| Found the answerThe update statement had some problemI put like thisUpdate tblImplementSchedule Set StateId=(Select @StateID) where State=@State |
 |
|
|
|
|
|