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 |
|
Kagen101
Starting Member
5 Posts |
Posted - 2005-09-30 : 02:30:09
|
| I have a function that returns a table, that I want to use to Update another table. The one colom is the colom name in the other table and the other colom is the value that the colom must change to.So we have thisidx colName Value0 col1 a1 col2 b2 col3 cI then construct a update query as follows and lets say the table it updates is called MyTable:So I first select the colom name and value from the above table(all variables have been declared):SELECT @tempColName = colName, @tempVal = value FROM @tempTable WHERE idx=1"idx is and int"UPDATE MyTable SET @tempColName = @tempVal WHERE someCol = somethingIt then tells me the rows have been effected but when I query the table it is still exactly like it was.Any idees why it does this and of a work around?ThanxK |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-10-01 : 00:07:04
|
| Post the exact code you're using please. This isn't working for anyone. Think about what you're doing in this example. Set @tempColName????MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-01 : 02:40:17
|
| Are you trying to read data from one table and want to update it with other table?If so, here is a general approachUpdate T1 set T1.col=T2.col from table1 T1 inner join table2 T2 on T1.primarycol=T2.primarycolOtherwise you need to give some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|