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 |
|
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] |
 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2009-03-27 : 02:43:42
|
| If u mean the sql way then you get it like thisdeclare @abc varchar(15)set @abc='gagan-garg'select SUBSTRING(@abc,0,charindex('-',@abc)) |
 |
|
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2009-03-27 : 02:58:29
|
| thnks ayamas & sakets_2000.........thnks a lot... |
 |
|
|
|
|
|