日期:2011-01-25 23:11:00 来源:本站整理
<b>速学若何定义SQL存储历程</b>[MSSQL防范]
本文“<b>速学若何定义SQL存储历程</b>[MSSQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
SQL存储历程在SQL数据库顶用处遍及,下面为您介绍若何定义SQL存储历程,假如您是刚接触SQL数据库的用户,无妨一看,但愿对您学习SQL存储历程有所帮忙.
<
- CREATE PROCEDURE get_tableinfo AS
- if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
- create table tablespaceinfo --成立后果存储表
- (nameinfo varchar(50) ,
- rowsinfo int , reserved varchar(20) ,
- datainfo varchar(20) ,
- index_size varchar(20) ,
- unused varchar(20) )
- delete from tablespaceinfo --清空数据表
- declare @tablename varchar(255) --表名称
- declare @cmdsql varchar(500)
- DECLARE Info_cursor CURSOR FOR
- select o.name
- from dbo.sysobjects o where OBJECTPROPERTY(o.id, N'IsTable') = 1
- and o.name not like N'#%%' order by o.name
- OPEN Info_cursor
- FETCH NEXT FROM Info_cursor
- INTO @tablename
- WHILE @@FETCH_STATUS = 0
- BEGIN
- if exists (select * from dbo.sysobjects where id = object_id(@tablename) and OBJECTPROPERTY(id, N'IsUserTable') = 1)
- execute sp_executesql
- N'insert into tablespaceinfo exec sp_spaceused @tbname',
- N'@tbname varchar(255)',
- @tbname = @tablename
- FETCH NEXT FROM Info_cursor
- INTO @tablename
- END
- CLOSE Info_cursor
- DEALLOCATE Info_cursor
- GO
以上是“<b>速学若何定义SQL存储历程</b>[MSSQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论