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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-11-17 : 10:30:00
|
| envirodat writes "I need to do a search and replace for string values in database where the colums could contain the data in many tables and different column names. Below is the SQL I have so far. DECLARE @CrsrVar Cursor @SQL nvarchar(4000)Set @CrsrVar = Cursor for SELECT table_name, column_name FROM information_schema.columns WHERE (column_name LIKE '%unit') AND (column_name Not LIKE '%base_unit%') ORDER BY table_nameOPEN @CrsrVarFetch Next from @CrsrVarWhile (@@Fetch_STATUS = 0) set @sSQL = 'UPDATE' + Fetch Next from @CrsrVarENDWhat need to do is a dynamic update in the while statement where I can pull the table and column names and put in the where clause conditions and the value that the new value will be updated to. I have searched BOL and this site but I haven't quite seen anything that does this. Could you please point in the right direction? Thanks." |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|