--INSERT INTO S_ReportCol
--SELECT 10001,name,'' FROM HotelPms.sys.columns WHERE object_id = OBJECT_ID('HotelPms.dbo.M_Building')

DELETE FROM S_ReportCol WHERE ReportID = 10000;

INSERT INTO S_ReportCol
SELECT 10000,A.column_id, A.name, CASE WHEN b.value IS NULL THEN A.name ELSE CAST(b.value AS NVARCHAR) END,GETDATE(),0,'',0 FROM HotelPms.sys.columns A
LEFT JOIN HotelPms.sys.extended_properties B ON A.object_id = B.major_id AND A.column_id = B.minor_id AND B.name='MS_Description'
WHERE object_id = OBJECT_ID('HotelPms.dbo.M_Demo')


DELETE FROM S_ReportCol WHERE ReportID = 10001;

INSERT INTO S_ReportCol
SELECT 10001,A.column_id, A.name, CASE WHEN b.value IS NULL THEN A.name ELSE CAST(b.value AS NVARCHAR) END,GETDATE(),0,'',0 FROM HotelPms.sys.columns A
LEFT JOIN HotelPms.sys.extended_properties B ON A.object_id = B.major_id AND A.column_id = B.minor_id AND B.name='MS_Description'
WHERE object_id = OBJECT_ID('HotelPms.dbo.M_Building')

DELETE FROM S_ReportCol WHERE ReportID = 10002;

INSERT INTO S_ReportCol
SELECT 10002,A.column_id, A.name, CASE WHEN b.value IS NULL THEN A.name ELSE CAST(b.value AS NVARCHAR) END,GETDATE(),0,'',0 FROM HotelPms.sys.columns A
LEFT JOIN HotelPms.sys.extended_properties B ON A.object_id = B.major_id AND A.column_id = B.minor_id AND B.name='MS_Description'
WHERE object_id = OBJECT_ID('HotelPms.dbo.M_RoomStatus')

--EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'¼Ì' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'M_Building', @level2type=N'COLUMN',@level2name=N'Name'