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 2008 Forums
 SSIS and Import/Export (2008)
 Parse String SSIS

Author  Topic 

Johnph
Posting Yak Master

103 Posts

Posted - 2014-03-18 : 11:24:34
Hello, I want to parse a string in SSIS. My strings looks like this:

CAT@@@DOG@@@yyyy
MOUSE@@@bbb@@@aaa
r@@@s@@@g

They are separated by @@@ and I need code that is able to pull the 1st or 2nd or 3rd characters.

Thanks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-03-18 : 18:06:32
[code]DECLARE @Sample TABLE
(
Data VARCHAR(100) NOT NULL
);

INSERT @Sample
(
Data
)
SELECT 'CAT@@@DOG@@@yyyy' UNION ALL
SELECT 'MOUSE@@@bbb@@@aaa' UNION ALL
SELECT 'r@@@s@@@g';

-- SwePeso
SELECT PARSENAME(Data, 3) AS [First],
PARSENAME(Data, 2) AS [Second],
PARSENAME(Data, 1) AS [Third]
FROM (
SELECT REPLACE(Data, '@@@', '.') AS Data
FROm @Sample
) AS d;[/code]


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

sqlsaga
Yak Posting Veteran

93 Posts

Posted - 2014-03-27 : 12:07:11
You can use a split function as well do it, why SSIS?

http://sqlsaga.com/sql-server/split-function-in-sql-server/

Just change your delimiter to what you need and it work fine..



Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Go to Top of Page
   

- Advertisement -