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 |
|
ConKi
Starting Member
2 Posts |
Posted - 2010-03-23 : 11:51:06
|
| Good morning,Could any one show me how to insert a comma in a string of 10 characters at position 2?Thank you so much,ConKi |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-03-23 : 11:55:12
|
Lots of ways.Here's an example using STUFFCheck the help installed with sql server -- it's really good -- just go to HELP -> INDEX in management studio and search for STUFFDECLARE @foo VARCHAR(255)SET @foo = 'asd;aksf;kasdg'SELECT @fooSELECT STUFF(@foo, 3, 0, ',') Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-03-23 : 11:56:28
|
| [code]select stuff(<urcolumn>,2,0,',') from <urtable>[/code] |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-03-23 : 11:57:01
|
|
 |
|
|
ConKi
Starting Member
2 Posts |
Posted - 2010-03-23 : 12:00:51
|
| Thank you so much. It worked. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-25 : 03:38:12
|
quote: Originally posted by ConKi Thank you so much. It worked.
Both the solutions are not sameWhich one worked?MadhivananFailing to plan is Planning to fail |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-03-25 : 05:10:59
|
| The only difference is that my one will insert immediately after the second character and vijayisonly's one will insert immediately after the first.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|
|