| Author |
Topic  |
|
|
cstokes91
Yak Posting Veteran
USA
52 Posts |
Posted - 01/29/2013 : 09:45:00
|
Hey,
This may be simple but I have been searching for this for a couple of hours now and haven't really been able to find anything on this.
I need a code that will take a string and stop when there is a line break for the length.
I've thought of substring(columnName, 0, (char(13)+char(10))) but it data type char is invalid for argument 3 of substring function.
Then I tried SUBSTRING(AlertInfo,0,CHARINDEX((CHAR(13)+CHAR(10)),AlertInfo,0))
This syntax wise ran good but returned empty values. |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 01/29/2013 : 09:52:12
|
SELECT STUFF(columnname,CHARINDEX(CHAR(10) + CHAR(13),columnname),LEN(columnname),'') FROM table
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
ScottPletcher
Yak Posting Veteran
USA
79 Posts |
Posted - 01/29/2013 : 14:41:35
|
I think a line break can be either CHAR(10) by itself or CHAR(13) + CHAR(10). So:
LEFT(AlertInfo, CHARINDEX(CHAR(10), REPLACE(AlertInfo, CHAR(13), '') + CHAR(10))
|
 |
|
| |
Topic  |
|
|
|