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)
 Find data between two comma positions

Author  Topic 

Rupa
Posting Yak Master

123 Posts

Posted - 2007-11-09 : 07:09:09
Hey all

I have an output from a csv file like:

Date, Time, StaffNo, Forename, Surname

I want StaffNo from the above. I know I need to use Substring and Charindex..but am kind of lost. I need something to say: give me data between comma position 2 and 3...

Any response will be highly appreciated.

Many thanks,

Rupa

Rupa
Posting Yak Master

123 Posts

Posted - 2007-11-09 : 07:36:40
I am becoming lazy...This worked for me:

(Substring(ErrorOutput, 21,(charindex(',',substring(ErrorOutput,21,datalength(ErrorOutput)-21)))-1))
AS StaffNo

Rupa
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-09 : 10:13:17
use this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -