반응형

/*******************************************************************************************************************
-- Title : [SQL2016] STRING_ESCAPE()를 활용한 JSON 형식 맞추기
-- Reference : www.dbrnd.com
-- Key word : string_escape strin_escape() json
*******************************************************************************************************************/

■ Scripts 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
-- It's not JSON
DECLARE @str1 VARCHAR(800= 'Anvesh''s blog is "dbrnd.com" which is running from 2015/05/01'
DECLARE @json1 VARCHAR(800= '[{"Name":"Anvesh","Gender":"Male","About":"'+@str1+'"}]'
 
SELECT @json1 as Json
SELECT ISJSON(@json1) IsJson
 
-- It's JSON
DECLARE @str2 VARCHAR(800= 'Anvesh''s blog is "dbrnd.com" which is running from 2015/05/01'
DECLARE @json2 VARCHAR(800= '[{"Name":"Anvesh","Gender":"Male","About":"'
                           + STRING_ESCAPE(@str2, 'JSON'+ '"}]'
SELECT @json2 as Json
SELECT ISJSON(@json2) IsJson
 
cs


반응형

+ Recent posts