Last active
July 8, 2018 23:54
-
-
Save CheetahChrome/865bee16a959c58e5da165806ae0413e to your computer and use it in GitHub Desktop.
SQL Server: Read Target Table and create a Declare statement usable in a stored procedure
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, | |
DATA_TYPE, | |
CHARACTER_MAXIMUM_LENGTH, | |
concat('DECLARE @', COLUMN_NAME, N' ', DATA_TYPE, | |
IIF(CHARACTER_MAXIMUM_LENGTH IS not null | |
, CONCAT(N' (', CHARACTER_MAXIMUM_LENGTH, N')') | |
, N'' | |
) | |
) AS [declare] | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE TABLE_NAME = 'Address' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The address Table: