Convert BLOB to String(Text) SQL Server

JosephTucker
Member Posts: 1
I have a BLOB stored in SQL Server. I've managed to convert it utilizing C/AL code, but I need to determine a way to convert it via SQL Query.
the C/AL code is:
OnAfterGetRecord()
CALCFIELDS(Rec."BLOB_FIELD", Rec."OTHER_BLOB_FIELD");
"BLOB_FIELD".CREATEINSTREAM(Istream);
Istream.READ(TextData);
CLEAR(Istream);
"OTHER_BLOB_FIELD".CREATEINSTREAM(Istream);
Istream.READ(OtherTextData);
//Istream is of type InStream
The above code seems to work just fine. However, for other purposes, I need to convert this within a SQL Query.
I have tried:
SELECT [No_], CONVERT(VARCHAR(MAX),CONVERT(VARBINARY(MAX),[blobField] )) FROM [foo$blobtable]
but I get data that does not seem to make sense
the C/AL code is:
OnAfterGetRecord()
CALCFIELDS(Rec."BLOB_FIELD", Rec."OTHER_BLOB_FIELD");
"BLOB_FIELD".CREATEINSTREAM(Istream);
Istream.READ(TextData);
CLEAR(Istream);
"OTHER_BLOB_FIELD".CREATEINSTREAM(Istream);
Istream.READ(OtherTextData);
//Istream is of type InStream
The above code seems to work just fine. However, for other purposes, I need to convert this within a SQL Query.
I have tried:
SELECT [No_], CONVERT(VARCHAR(MAX),CONVERT(VARBINARY(MAX),[blobField] )) FROM [foo$blobtable]
but I get data that does not seem to make sense
0
Answers
-
Kind of an old post, but for anyone still interested, you will need to set the Compression property on the field to No in NAV then use the following:
SELECT [No_], CONVERT(VARCHAR(MAX),CONVERT(VARBINARY(MAX),[blobField]),0) FROM [foo$blobtable]0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions