1. Implications and relationships of documents and filegroups
Each database has one master data file. and several from files. files are the physical embodiment of a database. Filegroups can include files that are distributed across multiple logical
Here's an excerpt of a text description of the trigger in the official SQL Server tutorial, which is really useful.
You can define a trigger that executes whenever you insert data into a table with an INSERT statement.
When the insert trigger is
Realize
1) have the same data, return directly (return value: 0);
2 has the same primary key, but the data different data, carries on the update processing (returns the value: 2);
3 No data, insert data processing (return value: 1).
"Create a
First look at a concept:
Database transaction (DB Transaction) is a series of operations performed as a single logical unit of work, either fully executed or completely not executed. Adding a transaction in a stored procedure guarantees that all of
SQL Server UPDATE statement is used to update data, the following is a detailed description of the syntax aspects of SQL Server update statements, hoping to give you a better understanding of SQL Server Update statements.
In real-world applications,
/************************************************************ * Code formatted by SETYG * TIME:2014/7/29 10:04:44
/CREATE PROC handleemailrepeat as DECLARE email CURSOR For SELECT E.email, E.orderno, E.trackingno from Email20140725 as e WHERE
By observing the execution plan, we found that the previous execution plan used a hash join for many of the large table connections, and that the query optimizer chose to use parallel execution, faster because of the large number of data involved in
Copy Code code as follows:
-->title: Generating test data
-->author:wufeng4552
-->date:2009-09-21 09:02:08
If object_id (' F_split ') is not null drop function F_split
Go
Create function F_split
(
@s varchar (8000),--string to be split
@
To be honest, the cursor has not been used for a long time using MS SQL Server. Similar functions were previously implemented using a while loop plus a temporary table. Just had a reference to the online example practice to write. Learn about cursor
Pattern matching in search conditions
The LIKE keyword searches for a string, date, or time value that matches a specified pattern. The LIKE keyword uses a regular expression to contain the pattern that the value will match. The pattern contains the
Empty records in all data tables in SQL Server
To empty records in all data tables:
Copy Code code as follows:
exec sp_msforeachtable @Command1 = ' truncate table? '
Delete all data tables:
Copy Code code as follows:
1. Char type:
Occupies 1 bytes for English (ASCII) characters, for a Chinese character 2 bytes, char storage fixed-length data is convenient, Char field index is very efficient, such as the definition of char (10), so whether you store data to
A typical method is to update or add to each data field in the primary table, and to delete all related records from the table before inserting. That is, every time you save, the data from the table is executed again to delete and insert the process.
The definition of a stored procedure,
A stored procedure (Stored Procedure) is a set of SQL statements that is compiled and stored in a database to complete a specific function, and the user specifies the name of the stored procedure and gives the
The code is as follows:
Copy Code code as follows:
Merging two columns of different DataTable into a new DataTable
Source table
Tables to be merged
Need to row the list (not to row the weight)
The maximum number of rows
The table is as follows:
How to get the following results:
Solution
Using XML transformations
The code is as follows:
Copy Code code as follows:
CREATE TABLE Body
(
ID int,
Body nvarchar (20)
)
Go
INSERT into the
Back up the database, and then use the following method:
Copy Code code as follows:
Use MASTER
Go
sp_configure ' ALLOW UPDATES ', 1 reconfigure with OVERRIDE
Go
ALTER DATABASE database_name SET Emergency
Go
sp_dboption '
Copy Code code as follows:
--Execution order from Where Select
SELECT * FROM
(select Sal as salary,comm as commission from EMP) x where salary--Draw Name Work as a Job
Select Ename + ' Work as a ' +job as msg from EMP where deptno=10
--If
Method One
Copy Code code as follows:
Declare @max integer, @id integer
Declare cur_rows cursor Local for select main field, COUNT (*) from table name Group by main field having count (*) > 1
Open Cur_rows
Fetch cur_rows into @
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.