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 |
|
uttam548
Starting Member
12 Posts |
Posted - 2009-01-27 : 01:53:29
|
| I need to SELECT the first sentence from a description field in a database table. Please suggest me how this can be done in SQL Server.Thanks. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-27 : 01:58:55
|
| use left, substring functions |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-27 : 02:02:46
|
| Can u Post ur database table along with data |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-27 : 02:08:43
|
| for example take the below query,declare @temp table ( val varchar(32))insert into @tempselect 'India is my country'select left(val,5) from @temp(or)select substring(val,1,charindex(' ',val,1)) from @temp |
 |
|
|
uttam548
Starting Member
12 Posts |
Posted - 2009-01-27 : 02:14:51
|
| Thanks Nageswar9 for your reply. It returns first word of the text provided.I solved my problem with this query."select left(description,CHARINDEX('.',description,0)) from news" |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-27 : 02:17:32
|
quote: Originally posted by uttam548 Thanks Nageswar9 for your reply. It returns first word of the text provided.I solved my problem with this query."select left(description,CHARINDEX('.',description,0)) from news"
welcome |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-27 : 02:27:32
|
| hi uttam,use like this tooselect case when CHARINDEX('.',description,0) > 0 then substring(description,1,CHARINDEX('.',description,0))else description end as col1 |
 |
|
|
|
|
|
|
|