| Author |
Topic |
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2011-11-14 : 14:30:42
|
| I have to apply an LTRIM statement to one particular column in a table. There are multiple tables in the database which have this column in common and i need to update all such tables/columns in that database. Is there a way to code this into a single statement as opposed to rewriting it multiple times for the different tables? The statement, as it is written now is:USE EvidenceUPDATE EVP_COCSET EVPNO=LTRIM(RTRIM(REPLACE(EVPNO,'RAV00EVP000','RCSO00EVP00')))thanksjames |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2011-11-14 : 14:54:06
|
| I know nothing of this 'code generator' you speak of. please 'splain.thanksjames |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2011-11-14 : 15:02:06
|
| Very much ranked as 'awesome'. This will come in handy as they start burying me with more 'stuff' here.thank you! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-14 : 23:42:42
|
| [code]EXEC sp_Msforeachtable 'UPDATE ?SET EVPNO=LTRIM(RTRIM(REPLACE(EVPNO,''RAV00EVP000'',''RCSO00EVP00'')))'[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-15 : 04:58:42
|
quote: Originally posted by visakh16
EXEC sp_Msforeachtable 'UPDATE ?SET EVPNO=LTRIM(RTRIM(REPLACE(EVPNO,''RAV00EVP000'',''RCSO00EVP00'')))' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Although this works, the procedure is undocumented and can be be removed from future release of SQL Server without any intimation. sp_makewebtask is one such system procedure which is not available from version 2008MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-15 : 06:47:11
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16
EXEC sp_Msforeachtable 'UPDATE ?SET EVPNO=LTRIM(RTRIM(REPLACE(EVPNO,''RAV00EVP000'',''RCSO00EVP00'')))' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Although this works, the procedure is undocumented and can be be removed from future release of SQL Server without any intimation. sp_makewebtask is one such system procedure which is not available from version 2008MadhivananFailing to plan is Planning to fail
Still it can be used as long as its one off activity and you're not going to put it in production ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|