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 |
|
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2009-03-28 : 15:17:56
|
| Can anyone help me with a query to find and replace data in SQL Server? I have two columns, and if the first column has data that begins with FLR1 (i.e. FLR1_ALARM), then I want to select the first 4 characters in the other column and replace them with FLR1. |
|
|
cshah1
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-03-28 : 15:37:07
|
| UPDATE myTABLESET Col2 = STUFF(col2,1,4,'FLR1')WHERE Col1 LIKE 'FLR1%' |
 |
|
|
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2009-03-28 : 15:46:09
|
| Is STUFF a sql command that basically says: STUFF(column to look in, starting character, number of characters, characters to replace with)? |
 |
|
|
cshah1
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-03-28 : 15:50:13
|
| Yes, it is a SQL String function. Look for its syntax in SQL Server Books Online (help document) |
 |
|
|
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2009-03-28 : 15:51:22
|
| Thanks for help, this may save me a considerable amount of time! |
 |
|
|
cshah1
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-03-28 : 15:59:12
|
You are welcome |
 |
|
|
|
|
|