Author |
Topic |
rintus
Starting Member
26 Posts |
Posted - 2008-10-01 : 19:40:08
|
I am trying to select the first 50 characters from a field. I tried the following SQLSelect name,roll_no,left(summary, 50) Summaryfrom studentSomehow it doesn't seem to work.Please suggest. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-02 : 04:49:59
|
what is the datatype of Summary field? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-02 : 05:09:39
|
Maybe there are many spaces in the beginning of the column value?Maybe there are many CR or LF in the beginning of the column value?Select name,roll_no,LEFT(REPLACE(REPLACE(REPLACE(Summary, CHAR(13), ' '), CHAR(10), ' '), ' ', ' '), 50) Summaryfrom student E 12°55'05.63"N 56°04'39.26" |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-02 : 05:14:07
|
quote: Originally posted by Peso Maybe there are many spaces in the beginning of the column value?Maybe there are many CR or LF in the beginning of the column value?Select name,roll_no,LEFT(REPLACE(REPLACE(REPLACE(Summary, CHAR(13), ' '), CHAR(10), ' '), ' ', ' '), 50) Summaryfrom student E 12°55'05.63"N 56°04'39.26"
may be Summary is of text dadatypeSelect name,roll_no,substring(summary,1,50) Summaryfrom student |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-02 : 05:19:10
|
There are many maybe's rigth now... E 12°55'05.63"N 56°04'39.26" |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-02 : 05:22:55
|
quote: Originally posted by Peso There are many maybe's rigth now... E 12°55'05.63"N 56°04'39.26"
Until OP comes back with what real problem is |
|
|
rintus
Starting Member
26 Posts |
Posted - 2008-10-02 : 09:54:54
|
It working now. Thanks :) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-02 : 10:01:27
|
What was the problem? E 12°55'05.63"N 56°04'39.26" |
|
|
rintus
Starting Member
26 Posts |
Posted - 2008-10-02 : 11:22:01
|
I was using DBVisualizer to run my queries and it was screwing up the results. When I use a different tool, it works fine. Thanks to all and sorry for the trouble. |
|
|
|