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 |
|
skysyb
Starting Member
16 Posts |
Posted - 2008-09-30 : 08:49:04
|
| Hi, sorry for the dumb question. But, is there a way to genarate update statements from the existing table and also using the values in the existing columns using T-SQL (and not wrting any procs) ?say for example , we have a table called table1 has the following columns & values like this. id, firstname, lastname, datetime 100 Bradley Mike Jan 01 2007 101 Smith Karen Jan 01 2007 now, i am trying something like this :select "update table1 set firstname='new firstname' where firstname=",firstname + "and id=", id from table1 where datetime = 'Jan 01 2007'.but it doesn't seem to be working and throwing some implicit varchar to int conversion errroscan someone help pls ?Thx |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-30 : 08:53:22
|
| Tryselect 'update table1 set firstname=''new firstname'' where firstname='''+firstname + ''' and id='+cast(id as varchar(10)) from table1 where datetime = 'Jan 01 2007'MadhivananFailing to plan is Planning to fail |
 |
|
|
skysyb
Starting Member
16 Posts |
Posted - 2008-09-30 : 09:55:46
|
| Thanks for the help Madhivanan. that perfectly works ! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-01 : 01:51:06
|
quote: Originally posted by skysyb Thanks for the help Madhivanan. that perfectly works !
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|