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 |
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2011-03-23 : 11:56:04
|
| how to escape comma from select statement? |
|
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2011-03-23 : 11:59:21
|
| my statement is like select name from temphere temp table contains column with commalike'john,mathues''nishu,mathues'so how to select this |
 |
|
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2011-03-23 : 12:11:08
|
| My column name is like 'john,mathues','nishu*baby'and 'john,mathues','nishu*baby' these are not the values. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-03-23 : 12:15:55
|
Many people here will tell you that it was a bad idea to put last name and first name together in a single column, and they would be right. But I won't dwell on that :--)What do you want your output to look like?john mathuesor mathusesor johnor something else?If you just want to get rid of the comma, and get "john mathues" do thisselect replace(YourColumn,',',' ') from YourTable But, that will get rid of ANY comma, for example if the name were "john,mathuses, III" you will lose both commas. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-03-23 : 12:46:18
|
quote: Originally posted by qutesanju My column name is like 'john,mathues','nishu*baby'and 'john,mathues','nishu*baby' these are not the values.
You should really conform your column names to Regular Identifiers (look in Books Online for: Rules for Regular Identifiers). Since you have already broken those rules, you can use a delimited identifier. SQL Server uses double-quotes ("") and square-brackets ([]) to denote a delimited identifier. For example: [john,mathues], [nishu*baby] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-03-24 : 04:28:17
|
You are having column names that are supposed to be column values MadhivananFailing to plan is Planning to fail |
 |
|
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2011-03-24 : 04:51:24
|
| The column names are generated dynamically using front end application |
 |
|
|
|
|
|
|
|