SQL Server-use table triggers to record table inserts, updates, rows deleted

In addition to the basics of table triggers, this article also uses a bit of knowledge.1. How to use SQL to get the current session user name and machine nameSelect current_user, HOST_NAME ()2. How to get the current table name in a table

SQL Server custom function functions call with AS

SET QUOTED_IDENTIFIER ONIdentifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marksSET QUOTED_IDENTIFIER OFFIdentifiers are not quoted and must comply with all Transact-SQL identifier rules.SET

Setting method for set IDENTITY_INSERT on and off in SQL Server

Set IDENTITY_INSERT on and off in SQL Server:Execute INSERT Database Insert data times the following error, I clearly did not give the primary key set value but still errorHere's how to fix it:Qlserver when you insert a record in bulk, set the SET

SQL Server copies the tables in the database to another database

In the process of using SQL Server, we may need to copy the table from one database to another, and today I'll show you how and how to do this. It may be a simple thing for most people, but it is better to record it than to write a good memory. Hope

SQL Server Learning--1

1. Remote Login mode2. Query the first 100 dataSelect top * FROM [dbo]. [Flow_share_day_tax]3. Get the system timeSELECT GETDATE () as ' current time 'Get other Time:DATEPART () returns an integer representing the specified date part of the

When MS SQL Server executes a large script file, it prompts the "out of memory" workaround

Problem Description:When a client server does not allow direct backup, it is often deployed by exporting database scripts-restoring the database,However, when the database export script is large, when you execute a script with Microsoft SQL Server

[SQL] SQL Server Basic Syntax

Struct Query Language1.3NFA. atomicityB. No data redundancyC. Referencing a primary key for another table2. ConstraintsA. Non-null constraintsB. PRIMARY KEY constraintsC. Unique constraintsD. Default ConstraintsE. Check constraintsF. FOREIGN KEY

SQL Server transactional backup and restore instances

1 Create DatabaseMyDB2 UseMyDB3 Go4 Create TableAccount (5Idvarchar( -),6Namevarchar( -),7Balancefloat8 )9 GoTen Select * from Account One A Insert intoAccount (ID, name, balance)Values('620101','Liyong', -) - Insert intoAccount (ID, name,

SQL Server Common commands

To view the locked table:Select request_session_id spid,object_name (resource_associated_entity_id) tableNameFrom sys.dm_tran_locks where resource_type= ' OBJECT 'SPID Lock Table ProcessTableName Locked Table nameUnlock:declare @spid intSet @spid = 5

SQL Server Backup Script

BACKUP database name to disk= ' D:\3333.bak '---Generate file names based on time--Assigning a SQL script to a variableDeclare @SqlBackupDataBase as nvarchar (1000)Set @SqlBackupDataBase =n ' BACKUP DATABASE House to DISK = ' E:\DBBackup\HOUSE-'

SQL Server exception Capture (Try Catch)

/*sqlserver exception capture in SQL Server database, if there are many stored procedures, we use dynamic SQL for stored procedure call stored procedure, at this time, it is possible to make a mistake at some point, but the error we can not trace to

How to use SQL Server common functions (continuous update)

Previously, I wanted to record some of the usual functions of SQL, but it has not been implemented ... Hey...Until today, the substring () function is used, and in C # The starting value of this method is 0, and the starting value in SQL is 1. Silly

SQL Server Syntax

Iv. RankingSorting and ranking is our most commonly used statistical method, such as the class of students according to the ranking of members, or according to the score of the students divided into several echelon: for example, the best results of

Resolve SQL Server Service remote Procedure call failure

method One: fix SQL Server:If you encounter a restart of the computer during the repair process:1. Press the key combination "Win" + "R" to bring up the running window2. Enter "regedit" and find the following location in the left-hand directory of

SQL Server self-built process for viewing table structure

Self-built process for viewing table structureCREATE PROC [Sp_tablehelp](@TableName VARCHAR( -)= "',@ColName VARCHAR( -)="') asBEGIN --table structure Quick Check --Brin --DECLARE @TableName VARCHAR (+) --DECLARE @ColName

SQL Server method for deleting duplicate data

Method OneDeclare @max integer,@id integer DeclareCur_rowscursorLocal for SelectMain field,Count(*) fromTable nameGroup byMain field having Count(*)> 1 Opencur_rowsFetchCur_rows into @id,@max while @ @fetch_status=0 begin Select @max = @max -1 Set

SQL Server deletes filegroups and files

File and filegroup deletion, if because the previous partition scheme is unreasonable, need to cancel partition, or partition in another way, you need to involve the deletion of files and filegroups, if not mastered the correct steps, sometimes can

Some methods of SQL Server to estimate and calculate the estimated number of rows are discussed.

Some methods of SQL Server to estimate and calculate the estimated number of rows are discussed. About the base Estimation in SQL Server 2014, the official document Optimizing Your Query Plans has a lot of details in the SQL Server 2014 Cardinality

SQL Server 2016 no-domain cluster configuration AlwaysON availability group graph tutorial, 2016 alwayson

SQL Server 2016 no-domain cluster configuration AlwaysON availability group graph tutorial, 2016 alwayson Both windows server 2016 and SQL server 2016 can be used to allow users not to join the AD, saving a lot of management operations, and there is

SQL where, group by, and having usage parsing, sqlhaving

SQL where, group by, and having usage parsing, sqlhaving If you don't talk much about it, paste the Code directly. The specific code is as follows: -- SQL where, group by, and having usage parsing -- if you want to use group by, you generally use

Total Pages: 923 1 .... 657 658 659 660 661 .... 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.