在动态编程中,我们需要获取表的结构数据,如表名,数据类型,精度等数据。你可以参考下面几行代码:
declare @table_name sysname = 'q' select t.table_name, c.column_name, c.data_type, c.numeric_precision, c.numeric_scale, isnull(character_maximum_length,0 ) as size from information_schema.tables as t inner join information_schema.columns c on (t.table_name = c.table_name) where t.table_name= @table_name order by t.table_name