Ms SQL Server: DDL trigger
DDL trigger (this article is on the Network)
1. DDL trigger event summary:When creating an event notification to monitor and respond to activities in the database or server instance, you can specify the corresponding
---- Allow updates to system tablesExec sp_configure 'Allow updates', 1Reconfigure with overrideGo
---- Unmark the ID columnUpdate syscolumns set colstat = 0 where id = object_id ('tablename') and colstat = 1Go
-- Insert rows with ID = 8001-8003.
Address: http://www.cnblogs.com/jfzhu/archive/2012/11/23/2785100.html
Reprinted please indicate the source
Method 1:
(1) Open Microsoft SQL Server Management studio and connect to SQL Server
(2) Right-click the SQL server root node and
Index cost
1. Added, changed, and deleted indexes are maintained.
2. Indexes occupy a certain amount of physical space
Indexing principles
1. The primary key must be indexed
2. Foreign keys must be indexed
3. It is best to create an index
The convert () function is a general function that converts a date to a new data type.
The convert () function can display date/time data in different formats.
Syntax:
Convert (data_type (length), date_to_be_converted, style)
Date_type
Create Function fun_getpy(@ STR nvarchar (4000))Returns nvarchar (4000)AsBegin
Declare @ word nchar (1), @ py nvarchar (4000)
Set @ py =''
While Len (@ Str)> 0BeginSet @ word = left (@ STR, 1)
-- If it is not a Chinese character, the original
Method 1
Declare @ Max integer, @ ID integerDeclare cur_rows cursor local for Select Main field, count (*) from table name group by main field having count (*)> 1Open cur_rowsFetch cur_rows into @ ID, @ MaxWhile @
Obtains the data of a field or several fields that have repeated entries.Select field1, field2 from Table group by field1, field2 having count (field1)> 1
Obtain the latest records with no repeated FieldsSelect top * from Table A where ID in
Retrieve table information
Select
Sysobjects. Name, SYS. extended_properties.value
From
Sysobjects
Left
Join
SYS. extended_properties
On
Sysobjects. ID
=
SYS. extended_properties.major_id
Where
Type
=
'
U
Use commands to create a userBelow is a simple example of adding a login account:Exec sp_addlogin 'pattern'RememberProgramUse the exec keyword before the name.The following is a complicated example of adding a new login account.Sp_addlogin 'sharonr',
Field Type
Description
Bit
0Or an integer of 1.
Int
Integer number from-2 ^ 31 (-2,147,483,648) to 2 ^ 31 (2,147,483,647)
Smallint
Integer number from-2 ^ 15 (-32,768) to 2 ^ 15 (32,767)
The specific implementation scheme of SQL full-text in exchange for time at the expense of space is as follows:
1: Create full-text in the SQL script. [assume that the loginname field (nvarchar), displayname field (nvarchar), and properties
the uniqueidentifier data type can store 16-byte binary values, which act the same as the Globally Unique Identifier (guid. GUID is the unique binary number: No duplicate guid value is generated on any two computers in the world.
in SQL,
Add foreign key constraints
Alter table dbo. account_userrole add foreign key (userid)References DBO. account_user (userid)
Delete Index
Drop index [user_publish_ischeck] on [DBO]. [user_publish]
Delete primary key
Alter table user_publish
Aggregate functions
AVG (numeric_expr) returns integer, decimal, money, float --- returns the average value of each value in the groupCount (* | column_name | distinct column_name) returns integer --- number of records in the returned table |
Select J. Name job name, P. step_id step number, P. step_name step name, P. Command run command,Case J. EnabledWhen 0 then 'deactivated'When 1 then 'enabled'Else ''end status,Case P. last_run_outcomeWhen 0 then 'failed'When 1 then 'success'Else
View
A view is actually a query result of one or more tables. The view displays data in a centralized manner, facilitating your query.
Advantages of a view:
1. Data Confidentiality
2. Simplified Query
3. Ensure logical independence of data
Enterprise-levelDatabaseMost applications are deployed inRaidThe disk array server can improve the disk access performance and implement fault tolerance/disaster tolerance.RAID (redundant disk array) is simply an array made of cheap hard disks. The
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.