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 2000 Forums
 Transact-SQL (2000)
 possible function...

Author  Topic 

daisy
Starting Member

13 Posts

Posted - 2005-05-17 : 11:29:33
i need to look up a job_id with an id
that is actually being used with another
element separated by a dash. e.g. 6080-1
how can i call only the first part, 6080?

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-05-17 : 11:58:26
try wildcards

like '6080%'
Go to Top of Page

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-05-17 : 11:58:28
LEFT(ColumnName,4)

OR

SUBSTRING(ColumnName,1,CHARINDEX('-',ColumnName,1)-1)

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-05-17 : 12:00:05
Assuming that your id's will have at most one dash in them:

select left([id], charindex('-', [id]) -1)
Go to Top of Page
   

- Advertisement -