CREATE PROCEDURE [dbo].[Usp_makespvariable] @tablename AS VARCHAR(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT '@' + i_s.COLUMN_NAME + ' ' + i_s.DATA_TYPE + ' ' + CASE WHEN i_s.DATA_TYPE LIKE '%char%' THEN '(' + CONVERT(VARCHAR, i_s.CHARACTER_MAXIMUM_LENGTH) + ')' ELSE '' END + ' , '
FROM INFORMATION_SCHEMA.COLUMNS AS i_s
LEFT OUTER JOIN sys.extended_properties AS s ON s.major_id = Object_id(i_s.TABLE_SCHEMA + '.' + i_s.TABLE_NAME)
AND s.minor_id = i_s.ORDINAL_POSITION
AND s.name = 'MS_Description'
WHERE ( Objectproperty(Object_id(i_s.TABLE_SCHEMA + '.' + i_s.TABLE_NAME), 'IsMsShipped') = 0 )
AND ( i_s.TABLE_NAME = @tablename )
ORDER BY i_s.ORDINAL_POSITION
END
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT '@' + i_s.COLUMN_NAME + ' ' + i_s.DATA_TYPE + ' ' + CASE WHEN i_s.DATA_TYPE LIKE '%char%' THEN '(' + CONVERT(VARCHAR, i_s.CHARACTER_MAXIMUM_LENGTH) + ')' ELSE '' END + ' , '
FROM INFORMATION_SCHEMA.COLUMNS AS i_s
LEFT OUTER JOIN sys.extended_properties AS s ON s.major_id = Object_id(i_s.TABLE_SCHEMA + '.' + i_s.TABLE_NAME)
AND s.minor_id = i_s.ORDINAL_POSITION
AND s.name = 'MS_Description'
WHERE ( Objectproperty(Object_id(i_s.TABLE_SCHEMA + '.' + i_s.TABLE_NAME), 'IsMsShipped') = 0 )
AND ( i_s.TABLE_NAME = @tablename )
ORDER BY i_s.ORDINAL_POSITION
END
No comments:
Post a Comment