SQL Server calls stored procedures summary _mssql

Source: Internet
Author: User

In the maintenance of SQL Server databases or Web development, it is sometimes necessary to invoke other stored procedures in other database operations, such as stored procedures or jobs, as described in the following methods of their invocation

A stored procedure called without an output parameter in SQL Server

SQL Code

--Definition of stored procedure
CREATE PROCEDURE [sys].[ Sp_add_product] 
(
  @m_viewcount int = 0
 , @m_hotcount int = 0
) as Go 
--call
 to stored procedure DECLARE @m_viewcount int
 declare @m_hotcount int
 exec sp_add_product @m_viewcount, @m_hotcount

Second, call stored procedures with output parameters in SQL Server

SQL Code

--Define stored procedures
CREATE PROCEDURE [sys].[ Sp_add_product] 
(
  @m_viewcount int = 0
 , @m_hotcount int output 
)-
-Declare of the stored procedure call
@m_ Viewcount int =0
declare @m_hotcount int 
exec dbo.sp_add_product @m_viewcount, @m_hotcount output

PS: Here is a description of SQL Server to find out which tables a field exists in

If the naming of a database is more canonical, it is convenient to use syscolumns system tables to query for results in SQL Server when we need to find out which tables a field exists in.

The following section of SQL code explains how SQL Server finds m_id in which tables.

Select Tab.name table_name, Col.name column_name from
 sysobjects tab left
 join syscolumns col on tab.id = col.id A nd tab.xtype = ' U '
 where col.name like '%m_id% ' ORDER by
 1,2

The above mentioned is the entire description of this article, I hope you like.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.