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.