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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 string question..

Author  Topic 

abcd
Yak Posting Veteran

92 Posts

Posted - 2009-03-27 : 02:08:21
hi all....
suppose i have a string as 'gagan-garg'
i want to select the words before '-'
how to do that in swl query???

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-27 : 02:41:34
[code]select left('gagan-garg',charindex('-','gagan-garg')-1)[/code]
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-03-27 : 02:43:42
If u mean the sql way then you get it like this

declare @abc varchar(15)
set @abc='gagan-garg'
select SUBSTRING(@abc,0,charindex('-',@abc))
Go to Top of Page

abcd
Yak Posting Veteran

92 Posts

Posted - 2009-03-27 : 02:58:29
thnks ayamas & sakets_2000.........
thnks a lot...
Go to Top of Page
   

- Advertisement -