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 |
|
monfu
Yak Posting Veteran
81 Posts |
Posted - 2008-05-12 : 09:53:57
|
| Dear All,I am populating some new tables from old tables, after I did some re-structuring to the database.I have created a table with langID and langCode.I also created a temptable, with the data being captured from an old table. The fields that are the most relevant at the moment are lid, and fk_langid.In the old table, lid, has strings in it, for example en, fr, bg etc, and fk_langId will be the foreign key to the new table. Now my problem is that there are some lid's which do not exist in the new table, and as so I need to hardcode an id for them in the new table.So I was doing something like this:-update #tempTableSET fk_langid = ( SELECT lid, CASE WHEN lid like '%sr%' THEN '1234' END FROM #tempTable )But I am getting an error:-Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.Can you help me out on how I can update the fk_langid in the temptable |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-05-12 : 09:56:42
|
| Try thisupdate #tempTableSET fk_langid = (SELECT lid=CASE WHEN lid like '%sr%' THEN '1234'ENDFROM #tempTable ) |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-12 : 09:57:18
|
| [code]update #tempTableSET fk_langid = CASE WHEN lid like '%sr%' THEN '1234' else lidEND[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
monfu
Yak Posting Veteran
81 Posts |
Posted - 2008-05-12 : 10:00:07
|
| yeps got thatwas going to post infactupdate #tempTableSET fk_langid = (--SELECT lid, CASE WHEN lid like '%sr%' THEN '1234'END--FROM #tempTable ) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-12 : 10:36:26
|
quote: Originally posted by monfu yeps got thatwas going to post infactupdate #tempTableSET fk_langid = (--SELECT lid, CASE WHEN lid like '%sr%' THEN '1234'END--FROM #tempTable )
Dont need the braces too |
 |
|
|
|
|
|
|
|