How to clean up error logs in ms SQL Server database

The SQL error log records various problems encountered during database operation and some important information. As a troubleshooting requirement, we usually do not take the initiative to clean up these log files. Only when the server is restarted,

Example of using exec to process small variables in SQL strings in SQL Server

SQL Server uses exec to process SQL strings containing variables. Prompt: the scalar variable @ must be declared (solved !)Copy codeThe Code is as follows:Declare @ tssj nvarchar (100) -- external variableDeclare @ SQL _ SQL nvarchar (100) -- save

Advantages and disadvantages of SQL Server Cluster servers

A "virtual" server composed of two or more physical independent servers is called a cluster server. A MicroSoft service called MicroSoft cluster service (MSC) manages cluster servers. An SQL Server cluster is a virtual Server composed of two or more

SQL server local administrator account cannot log on

These days I am going to talk about the SQL Server 2008 course. On the first day of today, the organizer prepared the environment to use the same virtual machine, and then distributed it to many experimental machines, the name of the brain is

SQL statement to query the field names of a table

The following describes how to write SQL statements for the field names of a query table. SQL statements can provide many functions. We hope that you can learn how to use SQL statements. Select name from syscolumns where id = (select id from

Meaning of four matching characters of SQL Server

The meaning of the four matching characters % indicates zero or multiple arbitrary characters. It indicates any character in the specified range []. Any single character [^] is not in the specified range. the character string must be enclosed in

Error 1813 when executing sp_attach_db in QA

Execute sp_attach_db or sp_attach_single_file_db in QA. The following message is displayed: Error 1813: failed to open the new database 'dbname'. create database will be terminated. Device activation error. The physical file name 'd: SQL

Judge whether the field is updated and new data is written into the Audit Log table.

To solve this problem, Insus. NET only creates another table, which stores the table to be tracked and the fields to be tracked in the table.Create another table [Audit], that is, the table storing the tracking records:Copy codeThe Code is as

Mssql Stored Procedure table name and field name as variables

Direct error reporting without using dynamic statementsIncorrectCopy codeThe Code is as follows:Alter proc testpapersAsBeginDeclare @ tems nvarchar (max), @ zidaun nvarchar (max)Set @ tems = select * from @ tems order by @ zidaunExec (@ tems)EndExec

SQL compares whether a set exists in another set.

Copy codeThe Code is as follows:DECLARE @ c INTDECLARE @ c2 INTSELECT @ c = COUNT (1)FROM dbo. SplitToTable ('1 | 2 | 3 | 4', '| ')SELECT @ c2 = COUNT (1)FROM dbo. SplitToTable ('1 | 2 | 3 | 4', '|')Inner join dbo. SplitToTable ('1 | 2 | 3 | ',' | ')

Stored Procedure Code for three types of SQL queries by PAGE

Copy codeThe Code is as follows:-- Based on MAX (MIN) IDCreate proc [dbo]. [proc_select_id]@ Pageindex int = 1, -- current page number@ Pagesize int = 10, -- size of each page@ Tablename VARCHAR (50) = '', -- table name@ Fields VARCHAR (1000) = '', -

Share multiple table join methods to update multiple different records at the same time

The following is a test example.1. Create two temporary tables and input test data:Copy codeThe Code is as follows:Create table # temptest1(Id int,Name1 varchar (50 ),Age int)Create table # temptest2(Id int,Name1 varchar (50 ),Age int) The

24-bit SQL monitoring table changes

Sometimes, we need to monitor the changes of a table in an important period, including insertion, update, and deletion. For example, when we export data to an external system, we want to export all the data, and it is best to export the changed data

SQL compound query condition (AND, OR, NOT) Processing of NULL values

The NULL value affects the query condition results, and the results are very subtle. The following table lists the true values of AND, OR, and not in SQL. Truth Table of table 1 AND TRUE FALSE NULL TRUE TRUE FALSE

Common SQL Server fuzzy query methods

Pattern Matching in search criteriaThe LIKE keyword searches for the string, date, or time value that matches the specified pattern. The LIKE keyword uses the regular expression to include the pattern to be matched by the value. The mode contains

SQL Server processing of NULL values in a field

Copy codeThe Code is as follows:-Determines whether some fields are empty.-- CaseSelect case when 'field name' is null then' \ n' else convert (varchar (20), 'field name') end as 'newname'Select case when null is null then' \ n' else convert

Stored Procedure for monitoring log File Size

1. Monitor servers and databases whose log files are larger than 10 GBCopy codeThe Code is as follows:Create procedure db_sendmail_mssqllogsizeAsDeclare @ SQL varchar (max), @ servername varchar (50), @ px int;DECLARE @ xml NVARCHAR (MAX)DECLARE @

Dangerous extension deletion and recovery code of sqlserver Database

Once met, almost crazy, a friend installed MSSQL, hurry and try to delete the following components. of course, the premise is that you have to delete your own database, otherwise many functions will not be available after the component is deleted.

Paging storage process (2) returns more accurate paging results in sqlserver

When I used the new SQL Server2005 function to construct the paging storage process, I mentioned using the ROW_NUMBER () function to replace top to implement the paging storage process.However, after a long time, we found a new problem, that is,

SQL statement exercise Example 6 absence (vacation) statistics in the Personnel System

Copy codeThe Code is as follows:--- This is an example in the human affairs system. It is required to record the employee's absence status.--- 1. Recording the absence score in the table is a penalty score for those who are often absent.--- Rules:---

Total Pages: 923 1 .... 564 565 566 567 568 .... 923 Go to: GO

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.