--select t2.name , * from sys.extended_properties t1
--inner join sys.tables t2 on t1.major_id = t2.object_id
--where t1.name = 'IsPlatform' and t1.value = '1'
DROP table #TableList
go
--Grab all the platform tables for the current DB
SELECT IDENTITY(INT,1,1) AS ID,
t2.name as Name
into #TableList
from sys.extended_properties t1
inner join sys.tables t2 on t1.major_id = t2.object_id
where t1.name = 'IsPlatform' and t1.value = '1'
DECLARE
@Loopid INT,
@MaxId INT
--Grab start and end values for the loop
SELECT @Loopid = 1,
@MaxId = MAX(ID)
FROM #TableList
DECLARE
@SQL NVARCHAR(500),
@TableName VARCHAR(400)
--This is where the loop starts
WHILE @Loopid <= @MaxId
BEGIN
--grab the function name and type
SELECT @TableName = name
FROM #TableList
WHERE ID = @Loopid
--Find out if it's a table-valued function
--print @tableName
set @SQL =
'EXEC sys.sp_addextendedproperty @name=N''CurrentVersion'', @value=N''1.1.1.1.'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''' + @TableName + ''''
PRINT @SQL
EXEC sp_executesql @sql
--construct the statement
--increment counter
SET @Loopid = @Loopid + 1
END
--clean up
DROP TABLE #TableList
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!