Created
March 24, 2023 07:14
-
-
Save mukarramjavid/2453cd407af963e73456deab66f20135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT '"' + COLUMN_NAME + '":'+ | |
CASE WHEN DATA_TYPE='NVARCHAR' THEN '"'+'VARCHAR(' + CAST(ISNULL(CHARACTER_MAXIMUM_LENGTH, 0) AS nvarchar(50))+') ' + | |
CASE WHEN IS_NULLABLE = 'NO' THEN 'NOT NULL' ELSE 'NULL'END+'",' ELSE '"'+DATA_TYPE+'(' + CAST(ISNULL(CHARACTER_MAXIMUM_LENGTH, 0) AS nvarchar(50))+') ' + | |
CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE 'NULL'END+'",' | |
END AS JsonFormat | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE TABLE_NAME = N'[table_name]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment