Home>

In the maintenance or web development of the SQL Server database, sometimes other stored procedures need to be called in other database operations such as stored procedures or jobs.The following describes the method it calls

In the maintenance or web development of the SQL Server database, sometimes other stored procedures need to be called in other database operations such as stored procedures or jobs.The following describes the method it calls

One, call the stored procedure without output parameters in sql server

sql code

-Definition of stored procedures
create procedure [sys]. [sp_add_product]
(
  @m_viewcount int=0
 ,@m_hotcount int=0
)
as
go
-Stored procedure call
 declare @m_viewcount int
 declare @m_hotcount int
 exec [email protected]_viewcount,@m_hotcount

Second, call the stored procedure 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
)
-Stored procedure call
declare @m_viewcount int=0
declare @m_hotcount int
exec [email protected]_viewcount,@m_hotcount output

ps:The following table introduces the SQL server to find which fields exist in a table

If the database is named fairly,When we need to find in which tables a field exists,It is very convenient to use the syscolumns system table to query the results in SQL Server.

The following piece of SQL code will explain to you how SQL Server looks for the tables in which m_id exists.

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 the entire description of this article.Hope you like it.

  • Previous Android programming battery power information update method (based on BatteryService)
  • Next Solve the problem of jquery_ujs component slowing down in Ruby on Rails