Home> Database> SQL> body text

Detailed graphic explanation of SqlServer's creation of automatic shrinking transaction log tasks

WBOY
Release: 2022-09-09 13:41:26
forward
2630 people have browsed it

This article brings you relevant knowledge aboutSQL server. There is a problem with the SQL Server database. If you limit the size of its log file, then when the database log reaches this size time, the database will stop writing logs. The following introduces the relevant information about SqlServer's task of creating automatic shrinking transaction logs. I hope it will be helpful to everyone.

Detailed graphic explanation of SqlServer's creation of automatic shrinking transaction log tasks

Recommended study: "SQL Tutorial"

1. Enter SSMS

##Click to expand the sqlserver agent, right-click "Jobs", and then select New Job.

2. Fill in the name

    #The name can be filled in casually, as long as it can represent the job task. Be concise and clear so that you can understand it later.
  • The owner selects sa or windows user. If remote operation is required, it is recommended to choose the sa account. Windows accounts only support local login and operation execution.
  • You can also fill in the description casually. Just understand it yourself.
3. Steps

    # Select the step on the tab page and click New
  • Fill in the step name as you like and remember it yourself Just stay.
  • Type selection tsql script
  • If you can choose the running identity, select the corresponding sa or windows identity (based on the previous one)
  • Database Select the database you want to shrink the log
  • Fill in the command content you edited (TSQL)
  • My command is as follows:
  • --将数据库设为简单模式。日志文件自动断开。 alter database dev_ecology set recovery simple; --查看日志文件状况 use dev_ecology; dbcc shrinkfile('dev_ecology_log') ; --恢复数据库模式 alter database dev_ecology set recovery full;
    Copy after login
Note above, change

dev_ecologyto your own The database name ofshrink_fileis generallyxxx_log. If you are not sure, you can use theselect * from sys.database_files;statement to query the log file name.

4. Select Advanced

If you only have this step and no other homework (like me).

    "Operation to be performed when successful" needs to select "Exit the job that reports success", otherwise the new job will report an error.
  • Then click OK

5. Create a new plan

    Click the plan tab on the left
  • Click New

6. Fill in the plan

    Write the name as you like, just remember it
  • Execution frequency I Select 0 o'clock every day, you can choose according to your needs.
  • The duration can be selected. Here I plan to let it be executed every day, so I won’t choose it.
  • After selecting, click Confirm

7. Click Confirm after the new creation is completed

8. Refresh and view the job

#Our shrink_log is ok.

9. Execute the job

If you are not sure, you can right-click the job task, select the job start step, and execute it immediately. (

Strongly recommended to be executed during the idle phase of the business)

Recommended study: "

SQL Tutorial"

The above is the detailed content of Detailed graphic explanation of SqlServer's creation of automatic shrinking transaction log tasks. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
sql
source:jb51.net
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!