Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All

Now I'm facing problem is
The one is data.
A50EA54A-BE80-41EC-BBDF-3EA2551F56C7;349D83CB-B3F7-4553-8D87-01F24222295E;DDB62DC7-7C41-4EDA-8DF6-101C05F3A3A6;32F2B8D0-8733-46E6-B508-20DD87534744;709FECD2-CF4C-4051-B339-E14D78829B31;2363E968-5852-488A-876E-E39EEEF0A8D1;016C8661-B321-49C0-8973-FF9CC0DF528A

I want to take of ; and want to declare with array.
Teach me
thz
Posted
Updated 7-Oct-14 18:19pm
v2
Comments
George Jonsson 7-Oct-14 23:54pm    
Array in what language? As far as I know SQL doesn't provide any arrays.
Is the data stored in one column? Looks like you should change the structure to use a new table for the GUIDs.
[no name] 8-Oct-14 0:19am    
what is your query and where is your problem

use Split function to Split the String by ';'

SQL
CREATE FUNCTION [dbo].[Split]
(
    @String NVARCHAR(4000),
    @Delimiter NCHAR(1)
)
RETURNS TABLE 
AS
RETURN 
(
    WITH Split(stpos,endpos) 
    AS(
        SELECT 0 AS stpos, CHARINDEX(@Delimiter,@String) AS endpos
        UNION ALL
        SELECT endpos+1, CHARINDEX(@Delimiter,@String,endpos+1)
            FROM Split
            WHERE endpos > 0
    )
    SELECT 'Id' = ROW_NUMBER() OVER (ORDER BY (SELECT 1)),
        'Data' = SUBSTRING(@String,stpos,COALESCE(NULLIF(endpos,0),LEN(@String)+1)-stpos)
    FROM Split
)

GO


SQL
SELECT * FROM [dbo].[Split] ('A50EA54A-BE80-41EC-BBDF-3EA2551F56C7;349D83CB-B3F7-4553-8D87-01F24222295E;DDB62DC7-7C41-4EDA-8DF6-101C05F3A3A6;32F2B8D0-8733-46E6-B508-20DD87534744;709FECD2-CF4C-4051-B339-E14D78829B31;2363E968-5852-488A-876E-E39EEEF0A8D1;016C8661-B321-49C0-8973-FF9CC0DF528A', ';') 


sql doesn't Provide arrays instead of that you can use temporary Table to store the Data'.
 
Share this answer
 
Hi,

You can store those seperated values in a temporary table.
Please try this link :http://www.aspdotnet-suresh.com/2013/07/sql-server-split-function-example-in.html[^]

Regards,
Praneet
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900