好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

SQL SERVER调用存储过程小结

在SQL Server 数据库 的维护或者Web开发中,有时需要在存储过程或者作业等其他数据库操作中调用其它的存储过程, 编程客栈 下面介绍其调用 编程 客栈 的方法

一、SQL SERVER中调用不带输出参数的存储过程

SQL 代码

--存储过程的定义
create procedure [sys].[sp_add_product] 
(
  @m_viewcount int = 0
 ,@m_hotcount int = 0
)
as
go 
--存储过程的调用
 declare @m_viewcount int
 declare @m_hotcount int
 exec sp_add_product @m_viewcount,@m_hotcount

二、SQL SERVER中调用带输出参数的存储过程

SQL 代码

--定义存储过程
create procedure [sys].[sp_add_product] 
(
  @m_viewcount int = 0
 ,@m_hotcount int output 
)
--存储过程的调用
declare @m_viewcount int =0
declare @m_hotcount int 
exec dbo.sp_add_product @m_viewcount,@m_hotcount output

ps:下面给大家介绍sql server 查找某个字段在哪些表中存在

如果数据库的命名是比较规范的,当我们需要查找某个字段在哪些表中存在时,在sql server中就很方便的利用syscolumns 系统 表查询出结果。

下面一段sql代码给大家讲解sql server 查找 m_Id 在哪些表中存在的方法

select tab.name table_name, col.name column_name
 from sysobjects tab
 left join syscolumns col o  编程  n tab.id = col.id and tab.xtype = 'U'
 where col.name like '%m_Id%'
 order by 1 python ,2

以上所述就是本文的全部叙述,希望大家喜欢 编程客栈 。

查看更多关于SQL SERVER调用存储过程小结的详细内容...

  阅读:19次