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 |
|
jpost
Starting Member
43 Posts |
Posted - 2012-09-19 : 13:53:43
|
| I am running a script that will return the first 5 character of a person's last name. The field does hold the entire name of the person, both last, first. If they have a four character last name, a comma appears to separate the field. However this cause me an issue when using it in an external program. Is there a command that I can use that can replace the comma in my results, like a contains? Here is the line of my script, which is apart of a larger one:selectleft(isnull(se.teacherdisplay,'') + space(5),5) as 'Homeroom'from section se |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-19 : 14:06:16
|
| use replace(field,',',' ') to replace comma to space. if you dont need space use '' instead------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-09-19 : 14:06:34
|
select left(isnull(replace(se.teacherdisplay,',',''),'') + space(5),5) as 'Homeroom'from section se |
 |
|
|
jpost
Starting Member
43 Posts |
Posted - 2012-09-19 : 14:24:04
|
| Works perfectly, thanks |
 |
|
|
|
|
|
|
|