question

asmagh-9402 avatar image
0 Votes"
asmagh-9402 asked MelissaMa-msft commented

convert a special caractere and split

hello , please i have a question a want to convert a special caractere so i can split it after that but my special caractere is like this
OBAFRAISOBAFRAIS-TAX

100604-inkedmicrosoftteams-image-li.jpg

here is the code that i used

select id , value from [dbo].[Details] cross apply string_split(Replace(cast(property as nvarchar(max)),'?',';'),';')


sql-server-transact-sql
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@asmagh-9402,

While asking a question you need to provide a minimal reproducible example:
(1) DDL and sample data population, i.e. CREATE table(s) plus INSERT, T-SQL statements.
(2) What you need to do, i.e. logic, and your attempt implementation of it in T-SQL.
(3) Desired output based on the sample data in the #1 above.
(4) Your SQL Server version (SELECT @@version;)

0 Votes 0 ·

Where ‘•’ becomes ‘’?


0 Votes 0 ·

Hi @asmagh-9402,

Could you please validate all the answers so far and provide any update?

If both are not working, please provide more sample data and expected output.

Please remember to accept the answers if they helped. Your action would be helpful to other users who encounter the same issue and read this thread. 

Thank you for understanding!

Best regards,
Melissa

0 Votes 0 ·
TomCooper-6989 avatar image
0 Votes"
TomCooper-6989 answered

Giving us the information that @YitzhakKhabinsky-0887 asked for is important to help us understand what you want. But here is a guess at what you are looking for.
Create Table #Sample(ID varchar(20), Property nvarchar(max));
Insert #Sample(ID, Property) Values('AASomething', N'OBAFRAISOBAFRAIS-TAX');
Select ID, value
From #Sample
Cross Apply String_Split(Replace(Property, Cast(0xFDF8 As nchar(1)), ';'), ';')

Tom

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MelissaMa-msft avatar image
0 Votes"
MelissaMa-msft answered

Hi @asmagh-9402,

Welcome to Microsoft Q&A!

You could have a try to replace 'nvarchar(max)' with 'varchar(max)' as below:

 select id , value from [dbo].[Details]  cross apply string_split(Replace(cast(property as varchar(max)),CHAR(63),';'),';')
    
 select id , value from [dbo].[Details]  cross apply string_split(Replace(cast(property as varchar(max)),'?',';'),';')
    
 select id , value from [dbo].[Details]  cross apply string_split(Replace(cast(property as varchar(max)),'',';'),';')

Best regards,
Melissa


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.