Table Scan, index Scan, index lookup three differencesWe often hear this three noun in our daily work, what does it mean? Under what circumstances will the above situation occur? And how can we optimize our SQL execution more efficiently when it
String functions
Name of function
Describe
Example
CHARINDEX
Finds the starting position of a specified string in another string
SELECT CHARINDEX (' Jbns ', ' My Jbns
Declaring local variablesDECLARE @ variable name data typeDECLARE @name varchar (8)DECLARE @seat intAssign valueSET @ Variable name = value orSELECT @ variable name = valueSET @name = ' Zhang San 'SELECT @name = studentname from Student WHERE
In the process of using the database, we often need to calculate some of the data first, and then query it out, so we need to create a function to accomplish this task.The function you create typically has two return types, one that returns a
INNER JOIN: (INNER join)Inner joins use comparison operators to match rows in two tables based on values in the universal columns of each table(1) SELECT ... From table 1INNER JOIN table 2ON ...SELECT S.sname,c.courseid,c.scoreFrom score as CINNER
CREATE Table Table Name(Column Name 1 characteristics of the data type column,Column Name 2 characteristics of the data type column,...)Note: Boolean True and FALSE can be converted to the following bit value: True converts to 1,false to 0Source:Use
Elect Collationproperty (' Chinese_prc_stroke_ci_ai_ks_ws ', ' CodePage ')--query SQL Server encoded format statementThe following is a comparison of query results:936 Simplified Chinese GBK950 Traditional Chinese BIG5437 US/Canada English932
The use of "'" (single quotation marks): In SQL Server, two "'" (single quotation marks) in the case of stitching strings, that is, the concatenation of a "'" single quote string.SELECT TOP 1 " '"+CONVERT(nvarchar( -), keyID)+" '"Name1
SQL Server of backup and recoverySQL Server:Backup command:BackupDatabase Testto disk = ' C:\Test 'With FORMAT,NAME = ' Full Backup of MyNwind 'The explanations are as follows:NAME = ' Full Backup of MyNwind '-this is the remark, write it
--page (starting from 1) pagesize--Method 1 (not high efficiency):SELECT TOP ten * from [XXX]. [Oooo]WHEREID not in(SELECT TOP (10* (3000-1)) ID from [XXX]. [Oooo] ORDER by Createtime DESC)ORDER by Createtime DESC;Method 2 (High efficiency):SELECT
operating mode:At a large level, there are only two modes of SQL Server mirroring: High security mode and high performance mode. The main difference between the two modes is the operation after the transaction is committed. You can view the run mode
Method One: Take advantage of cursors, but be aware of the main field or identity columnDeclare @max integer,@id integerDeclareCur_rowscursorLocal for SelectMain field,Count(*) fromTable nameGroup byMain field having Count(*)> 1Opencur_rowsFetchCur_
Just say the principle, you can use the program to generate HTM or Word documents.1, first get all the tablesSELECT name, id from sysobjects WHERE xtype = ' u ' ORDER by name ASC2. Query the field information according to the table nameSelect
For production data, the security of data is critical, and any loss of data can have serious consequences. Backup as a copy of the data, can effectively protect and restore dataReasons for data lossThe main reasons for data loss include the
Back up before modifying or deleting data, back up first, back up (important things say three times)!1, first, look at the thread, analyze whether there is a blocking process, blocked>0 are currently blocked processesSELECT * from sysprocesses where
DECLARE @Str NVARCHAR( -)= '1_bb_cc_dd_aa_ee_yy_ww_hh_gg'--//1. Gets the number of times an underscore appears in a stringSELECT LEN(@Str)- LEN(REPLACE(@Str,'_',"'))--//2. Get the subscript where the underline appearsIF EXISTS(SELECT *
SQL Server is a database management system that runs primarily through windows services. This article mainly introduces how to perform basic operation and management of the database.Start or stop the database serviceAfter you complete the database
SQL Server is a database management system that runs primarily through windows services. This article mainly introduces how to perform basic operation and management of the database.Start or stop the database serviceAfter you complete the database
Although it is not recommended to use commands to delete things in a database table, these delete commands are always useful.When it comes to deleting table data, the biggest thing you can remember is the delete.However, we do database development
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.