亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

SQL Server編寫存儲過程小工具(二)

瀏覽:107日期:2023-10-29 15:11:04

SQL Server編寫存儲過程小工具 以下是兩個存儲過程的源程序 /*===========================================================

語法: sp_GenInsert <Table Name>,<Stored Procedure Name> 以northwind 數(shù)據(jù)庫為例 sp_GenInsert 'Employees', 'INS_Employees'

注釋:如果您在Master系統(tǒng)數(shù)據(jù)庫中創(chuàng)建該過程,那您就可以在您服務(wù)器上所有的數(shù)據(jù)庫中使用該過程。

=============================================================*/

CREATE procedure sp_GenInsert @TableName varchar(130), @ProcedureName varchar(130) as set nocount on

declare @maxcol int, @TableID int

set @TableID = object_id(@TableName)

select @MaxCol = max(colorder) from syscolumns where id = @TableID

select 'Create Procedure ' + rtrim(@ProcedureName) as type,0 as colorder into #TempProc union select convert(char(35),'@' + syscolumns.name) + rtrim(systypes.name) + case when rtrim(systypes.name) in ('binary','char','nchar','nvarchar','varbinary','varchar') then '(' + rtrim(convert(char(4),syscolumns.length)) + ')' when rtrim(systypes.name) not in ('binary','char','nchar','nvarchar','varbinary','varchar') then ' ' end + case when colorder < @maxcol then ',' when colorder = @maxcol then ' ' end as type, colorder from syscolumns join systypes on syscolumns.xtype = systypes.xtype where id = @TableID and systypes.name <> 'sysname' union select 'AS',@maxcol + 1 as colorder union select 'INSERT INTO ' + @TableName,@maxcol + 2 as colorder union select '(',@maxcol + 3 as colorder union select syscolumns.name + case when colorder < @maxcol then ',' when colorder = @maxcol then ' ' end as type, colorder + @maxcol + 3 as colorder from syscolumns join systypes on syscolumns.xtype = systypes.xtype where id = @TableID and systypes.name <> 'sysname' union select ')',(2 * @maxcol) + 4 as colorder union select 'VALUES',(2 * @maxcol) + 5 as colorder union select '(',(2 * @maxcol) + 6 as colorder union select '@' + syscolumns.name + case when colorder < @maxcol then ',' when colorder = @maxcol then ' ' end as type, colorder + (2 * @maxcol + 6) as colorder from syscolumns join systypes on syscolumns.xtype = systypes.xtype where id = @TableID and systypes.name <> 'sysname' union select ')',(3 * @maxcol) + 7 as colorder order by colorder

select type from #tempproc order by colorder

drop table #tempproc

標(biāo)簽: Sql Server 數(shù)據(jù)庫
主站蜘蛛池模板: 亚洲综合激情六月婷婷在线观看 | 免费黄色a| 不卡的在线视频免费观看 | 国产精品videosse | 国产露出调教91 | 国产乱码精品一区二区三区四川人 | 夜夜爱夜夜操 | 外国一级黄色片 | 中文字幕日产乱码偷在线 | 99草在线视频 | 九九视频免费在线 | 一男一女野外大黄毛片 | 成人精品国产亚洲 | 99久久精品免费精品国产 | 国产一区二区三区免费播放 | 成人午夜精品 | 国产成人免费片在线视频观看 | 成人免费男女视频网站慢动作 | 高清国产美女在线观看 | ⅹxx中国xxx人妖 | 亚洲一级影院 | 亚洲国产精品久久久久婷婷老年 | 草草影院ccyy国产日本欧美 | 欧美一级色片 | 精品欧美一区二区在线看片 | 国产床戏做爰免费观看网站 | 欧美自拍色图 | 国产成人久久精品 | 国产日韩欧美亚洲综合首页 | 久久永久免费中文字幕 | 91视频三级| 成人禁啪啪网站 | 热久久综合这里只有精品电影 | 亚洲国产精品自产拍在线播放 | 国产高清网站 | 亚洲一区免费视频 | 国产亚洲人成网站在线观看 | 精品欧美 | 国产美女主播一级成人毛片 | 亚洲国产精品区 | 河南毛片 |