Summary of SQL server calling stored procedures and SQL stored procedures

Source: Internet
Author: User

Summary of SQL server calling stored procedures and SQL stored procedures

In the maintenance or Web development of the SQL Server database, you sometimes need to call other stored procedures in the stored procedures, jobs, and other database operations. The following describes how to call the stored procedures.

I. stored procedures without output parameters called in SQL SERVER

SQL code

-- Create procedure [sys]. [sp_add_product] (@ m_viewcount int = 0, @ m_hotcount int = 0) asgo -- call the Stored Procedure declare @ m_viewcount int declare @ m_hotcount int exec sp_add_product @ m_viewcount, @ m_hotcount

Ii. SQL SERVER calls stored procedures with output parameters

SQL code

-- Define the stored procedure create procedure [sys]. [sp_add_product] (@ m_viewcount int = 0, @ m_hotcount int output) -- call declare @ m_viewcount int = 0 declare @ m_hotcount int exec dbo for stored procedures. sp_add_product @ m_viewcount, @ m_hotcount output

Ps: The following describes the tables in which a field exists in SQL server.

If the database name is standardized, when we need to find the tables in which a field exists, it is convenient to use the syscolumns system table to query the results in SQL server.

The following SQL code explains how to find tables in which m_Id exists on SQL server.

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

The above is all about this article. I hope you will like it.

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.