Wednesday, June 6, 2012

Đẩy dữ liệu cho MetaData

use [QLDT_tiensi]
DECLARE @tbName nvarchar(100)
declare @colName nvarchar(100)
DECLARE @lst CURSOR

SET @lst = CURSOR FOR
    SELECT table_name, column_name
    FROM INFORMATION_SCHEMA.COLUMNS
   
OPEN @lst

FETCH NEXT
FROM @lst INTO @tbName,@colName

WHILE @@FETCH_STATUS = 0
BEGIN
    print @tbname + ' ' + @colName
    if (not exists( select * from tbMeta where tenbang = @tbName and tentruong = @colName))
        insert into tbMeta(tenbang,tentruong, dorong, [text],[control]) values(@tbName,@colName, 80,'','TextBox');   
FETCH NEXT
FROM @lst INTO @tbName,@colName
END
CLOSE @lst
DEALLOCATE @lst

No comments:

Post a Comment