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
 Text Delimiter Query (Simple one!)

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-08-13 : 09:56:00
Hi All - I have the following Table:

LOCATION
Toronto: Ontario
Winnipeg: Manitoba
Montreal: Quebec
Oakfield: Ontario

I need to use a text function so that it will output all the characters BEFORE the colon. How can I acheive this? Thanks!

LOCATION
Toronto
Winnipeg
Montreal
Oakfield

[CODE]
SELECT LOCATION FROM TABLE
[/CODE]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-13 : 09:58:27
[code]
SELECT LEFT(LOCATION,CHARINDEX(':',LOCATION + ':')-1) AS LocVal FROM Table
[/code]

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

Go to Top of Page

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-08-13 : 10:02:02
THANKS VISAKH !!!!!!!!!!!!!!!!!!!!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-13 : 10:03:46
welcome!!!!!

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

Go to Top of Page
   

- Advertisement -