| @tbl nvarchar(200),@fld nvarchar(200),@sql nvarchar(4000),@maxlen int,@sample nvarchar(40)
select d.name TableName,a.name FieldName,b.name TypeName,a.length Length,a.isnullable IS_NULL into #t from syscolumns a, systypes b,sysobjects d where a.xtype=b.xusertype and a.id=d.id and d.xtype='U'
declare read_cursor cursor for select TableName,FieldName from #t
select top 1 '_TableName ' TableName, 'FieldName ' FieldName,'TypeName ' TypeName, 'Length' Length,'IS_NULL' IS_NULL, 'MaxLenUsed' as MaxLenUsed,'Sample Value ' Sample, 'Comment ' Comment into #tc from #t
open read_cursor
fetch next from read_cursor into @tbl,@fld
while (@@fetch_status <> -1) --- failes begin if (@@fetch_status <> -2) -- Missing begin set @sql=N'set @maxlen=(select max(len(cast(' @fld ' as nvarchar))) from ' @tbl ')' --PRINT @sql exec SP_EXECUTESQL
|
| 共16页: 上一页 [1] [2] 3 [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] 下一页 |
评论加载中…