创建一个存储过程,通过传进的表名参数,返回该表的主键。其存储过程代码如下:
CREATE
Proc pGetPkColumn (@tableName varchar(50)) as
Create By Peopleyl
获得所要导进数据表的主动递增列
*/ declare @columnName varchar(500) set @columnName = ’’ SELECT @columnName = @columnName +’,’+ c。
Name FROM
sysindexes i,
sysindexkeys k,
sysobjects o,
syscolumns c,
systypes d WHERE
i。Name like ’pk_%’
AND o。id=i。
id
AND o。xType=’U’
AND i。id = k。id
AND i。indid = k。indid
AND i。id = o。id
AND i。id = c。id
AND k。colid = c。colid
and i。
indid 0
and i。indid
0