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
 General SQL Server Forums
 New to SQL Server Programming
 selecting specific data values

Author  Topic 

ssury
Starting Member

1 Post

Posted - 2010-11-19 : 16:00:25
Hi, does anyone know what the format of a select statement would be if I want to select data before the "-" in the following: 12345678-90? Thanks!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-19 : 16:04:24
select left(@str,charindex('-',@str)-1)

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-21 : 04:07:37
beware that this might break if you're having data without - in field or variable you're trying to retrieve the result.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -