几段SQLServer语句和存储过程then 'case when '+ name +' is null then ''NULL'' else '+''''''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as Char(' + cast(length as varchar) + '))+'''''''''+' end' when xtype in (239) then 'case when '+ name +' is null then ''NULL'' else '+'''N'''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as Char(' + cast(length as varchar) + '))+'''''''''+' end' else '''NULL''' end as Cols,name from syscolumns where id = object_id(@tablename) ) T set @sql ='select ''INSERT INTO ['+ @tablename + ']' + left(@sql,len(@sql)-1)+') ' + left(@sqlValues,len(@sqlValues)-4) + ')'' from '+@tablename --print @sql exec (@sql) end GO -- ====================================================== --根据表中数据生成insert语句的存储过程 --建立存储过程,执行 proc_insert 表名 --感谢Sky_blue -- ====================================================== CREATE proc proc_insert (@tablename varchar(256)) as begin set nocount on 上一篇:在SQLSERVER2005中实现素数计算 下一篇:SQLServer2005的一般部署步骤 更多相关文章
|
推荐文章
精彩文章
|