Home Database Mysql Tutorial Introduction to SQL SERVER automatically executing stored procedures

Introduction to SQL SERVER automatically executing stored procedures

Jun 16, 2017 am 11:15 AM

How to execute a stored procedure when starting SQL SERVER?

Create the stored procedure in the master database, and then find the stored procedure in the Enterprise Manager--right-click--Properties--check "Execute whenever sql server starts".

 --Or after creating the stored procedure in the master, set the execution statement to automatically start

 use master

 exec sp_procoption 'stored procedure name','startup',' on'
------------------------------------------------ ------------------

Automatically execute stored procedures

SQL Server can automatically execute one or more a stored procedure. These stored procedures must be created by a system administrator and executed as background processes under the sysadmin fixed server role. These procedures cannot have any input parameters.

There is no limit on the number of startup processes, but please note that each startup process will occupy a connection when executed. If multiple procedures must be executed at startup, but do not need to be executed in parallel, you can designate one process as the startup procedure and have it call other procedures. This only takes up one connection.

After the last database is restored at startup, the stored procedure begins to be executed. To skip execution of these stored procedures, specify the startup parameter as trace flag 4022. If you start SQL Server with minimal configuration (using the -f flag), the startup stored procedure will also not execute. For more information, see Trace Tags.

To create a startup stored procedure, you must be logged in as a member of the sysadmin fixed server role and create the stored procedure in the master database.

Use sp_procoption to:

Specify an existing stored procedure as the startup procedure.

Prevents the process from executing when SQL Server starts.


The above is the detailed content of Introduction to SQL SERVER automatically executing stored procedures. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Automount drives on Linux Automount drives on Linux Mar 20, 2024 am 11:30 AM

If you are using a Linux operating system and want the system to automatically mount the drive on boot, you can do this by adding the device's unique identifier (UID) and mount point path to the fstab configuration file. fstab is a file system table file located in the /etc directory. It contains information about the file systems that need to be mounted when the system starts. By editing the fstab file, you can ensure that the required drives are loaded correctly every time the system starts, thus ensuring stable system operation. Automatically mounting drivers can be conveniently used in a variety of situations. For example, I plan to back up my system to an external storage device. To achieve automation, ensure that the device remains connected to the system, even at startup. Likewise, many applications will directly

Automatic thumbnail generation using JavaScript Automatic thumbnail generation using JavaScript Jun 16, 2023 pm 12:51 PM

With the development of the Internet, pictures have become an indispensable part of web pages. But as the number of images increases, the loading speed of images has become a very important issue. In order to solve this problem, many websites use thumbnails to display images, but in order to generate thumbnails, we need to use professional image processing tools, which is a very troublesome thing for some non-professionals. Then, using JavaScript to achieve automatic thumbnail generation becomes a good choice. How to use JavaS

PHP and PHPMAILER: How to implement automatic filtering of mail sending? PHP and PHPMAILER: How to implement automatic filtering of mail sending? Jul 21, 2023 am 09:25 AM

PHP and PHPMAILER: How to implement automatic filtering of mail sending? In modern society, email has become one of the important ways for people to communicate. However, with the popularity and widespread use of email, the amount of spam has also shown an explosive growth trend. Spam emails not only waste users' time and network resources, but may also bring viruses and phishing behaviors. Therefore, when developing the email sending function, it becomes crucial to add the function of automatically filtering spam. This article will introduce how to use PHP and PHPMai

Linux Tips: Cancel automatic indentation when pasting in vim Linux Tips: Cancel automatic indentation when pasting in vim Mar 07, 2024 am 08:30 AM

Preface: vim is a powerful text editing tool, which is very popular on Linux. Recently, I encountered a strange problem when using vim on another server: when I copied and pasted a locally written script into a blank file on the server, automatic indentation occurred. To use a simple example, the script I wrote locally is as follows: aaabbbcccddd. When I copy the above content and paste it into a blank file on the server, what I get is: aabbbcccddd. Obviously, this is what vim does automatically for us. Format indentation. However, this automatic is a bit unintelligent. Record the solution here. Solution: Set the .vimrc configuration file in our home directory, new

What software is microsoft sql server? What software is microsoft sql server? Feb 28, 2023 pm 03:00 PM

Microsoft SQL Server is a relational database management system launched by Microsoft. It is a comprehensive database platform that uses integrated business intelligence (BI) tools to provide enterprise-level data management. It is easy to use, has good scalability, and has a high degree of integration with related software. High advantages. The SQL Server database engine provides more secure and reliable storage functions for relational data and structured data, allowing users to build and manage highly available and high-performance data applications for business.

SQL Server or MySQL? New research reveals the best database choices. SQL Server or MySQL? New research reveals the best database choices. Sep 08, 2023 pm 04:34 PM

SQLServer or MySQL? The latest research reveals the best database selection. In recent years, with the rapid development of the Internet and big data, database selection has become an important issue faced by enterprises and developers. Among many databases, SQL Server and MySQL, as the two most common and widely used relational databases, are highly controversial. So, between SQLServer and MySQL, which one should you choose? The latest research sheds light on this problem for us. First, let

PHP and SQL Server database development PHP and SQL Server database development Jun 20, 2023 pm 10:38 PM

With the popularity of the Internet, website and application development has become the main business of many companies and individuals. PHP and SQLServer database are two very important tools. PHP is a server-side scripting language that can be used to develop dynamic websites; SQL Server is a relational database management system developed by Microsoft and has a wide range of application scenarios. In this article, we will discuss the development of PHP and SQL Server, as well as their advantages, disadvantages and application methods. First, let's

How to connect to a Microsoft SQL Server database using PDO How to connect to a Microsoft SQL Server database using PDO Jul 29, 2023 pm 01:49 PM

Introduction to how to use PDO to connect to a Microsoft SQL Server database: PDO (PHPDataObjects) is a unified interface for accessing databases provided by PHP. It provides many advantages, such as implementing an abstraction layer of the database and making it easy to switch between different database types without modifying a large amount of code. This article will introduce how to use PDO to connect to a Microsoft SQL Server database and provide some related code examples. step

See all articles