Copy CodeThe code is as follows:
/*01.
Introduction to 02.sql XML:
--by Jinjazz
--http://blog.csdn.net/jinjazz
25l
06.1, XML: Ability to recognize elements, attributes, and values
07.
08.2, XPath: Addressing language, lookup similar to Windows directory (go to the wall if you don't use the dir command)
09.
10. Syntax format, which can be combined as a condition:
11. "." Express oneself, "..." Said the father, "/" said the Son, "//" to indicate the off
:A. Needs to be queried from the database: Totalrecords. "SELECT COUNT (*) from TableName"B. The most basic needs of user-provided: PageSize and Pagenow. (Personally think this is the premise of pagination algorithm)C. Derived from other variables: TotalPages, Beginrow and Endrow. (it needs to be calculated that Beginrow and endrow are required for paging queries, TotalPages is the information that the page needs to provide). Specific formula for calculation:
Totalpages:if ((totalrecord
Table structureTable DataSQL as followsWith Lmenu as (select name,id,1 as lv,cast (name as nvarchar (max)) as name1, cast (Row_number () Up (order by GETDATE ()) as N varchar () as OrderID from Table2 where table2.parentid=0 Union all Select A.name, a.ID, (b.lv+1) as LV, Cast (REPLICATE (" , b.lv*2) + a.name as nvarchar (max)) as name1, cast ((b.orderid+ '. ') + CAST (Row_number () over (Order by GETDATE ()) as nvarchar (5))) as nvarchar (ten)) as OrderID from Table2 as a inner j Oin Lm
SQL Server query and Kill deadlock statement, sqlserverkill
Query deadlock process statements
select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT'
Statement used to kill a deadlock
kill spid
Next, I will share with you a piece of inform
Objective
In this section we'll talk about simple query examples and places to look at, short content, and deep understanding.
EOMONTH
In the tutorial example of SQL Server 2012, for queries on sales.orders tables, you need to return orders for the last day of the month. Our general enquiry is as follows
Use TSQL2012
go
SELECT OrderID, OrderDate, CustI
I once met a user who has a very large MSDB database and asked me to help find out why. Use sp_spaceused to find the data size of all tables. The problem is that SQL Server
I once met a user who has a very large MSDB database and asked me to help find out why. Use sp_spaceused to find the data size of all tables. The problem is that SQL
Copy codeThe Code is as follows: -- PK
Select * from sys. key_constraints where object_id = OBJECT_ID ('tb ')
-- FK
Select * from sys. foreign_keys where parent_object_id = OBJECT_ID ('tb ')
-- Create a linked server
Exec sp_addrole server 'itsv', '', 'sqloledb', 'remote server name or IP address'
Exec sp_add1_srvlogin 'itsv', 'false', null, 'username', 'Password
The SQL Server compact product group published a blog article about how to improve the query performance of the SQL Server compact database. It is comprehensive and authoritative. We suggest you take a look. In fact, the SQL
The most obvious feature of SQL differs from other programming languages is the order in which the code is processed. In a large number programming language, code is processed in encoded order, but in the SQL language, the first processed clause is the FROM clause, although the SELECT statement first appears, but is almost always finally processed.Each step produces a virtual table that is used as input to
Atitit.mysql the use of the Oracle with AS Mode temp table pattern CTE statement to reduce the structural MSSQL SQL for subqueries Server:1. With ... as (...) in the MySQL what should be said in 12. Sub-query and query nesting is mainly easy to improve readability, 23. the solution in MYSQL :: temp table. 24. Seo bla
Deadlock) refers to the state in which processes are permanently blocked. SQL can detect deadlocks and terminate a transaction to intervene in the deadlock State. A typical example of A deadlock between two processes is: Obtain lock A in process T1 and apply for lock B; obtain lock B in process T2 and apply for lock A. Here we will demonstrate this situation:
1. Create a Database named InvDB.
2. Execute the following script to create the person table
The company database grows with time, the data is more and more, the query speed is also more and more slow. Into the database to see a bit, hundreds of thousands of of the data, the query is really time-consuming.To improve the query performance of SQL, we generally consider the index as the first consideration. In fa
commas.When the FROM clause specifies multiple tables or views at the same time, if the same column exists in the selected list, use the object name to limit these columns.The table or view. For example, if the usertable and citytable tables contain the cityid column at the same time, the following statement format should be used to limit the cityid column when querying the two tables:SELECT username, citytable. cityidFROM usertable, citytableWHERE usertable. cityid = citytable. cityidYou can s
stored procedure.
In particular, do not use nested views. nested views increase the difficulty of searching for original data. Let's look at the nature of the View: it is stored on the server.
The optimized SQL query plan has been generated. When retrieving data from a single table, do not use a view pointing to multiple tables.
You can retrieve or read the view
datename (interval,date) that corresponds to the specified part of the date, interval returns the string name for the specified portion of the date, intervalThe setting values for the parameter interval are as follows:Value abbreviations (SQL Server) Access and ASP descriptions YearYy yyyy Year1753 ~ 9999Quarter Qq Q season1 ~ 4MonthMm m Month 1~ A Day of YearDy y number of days of the year, the Day of
Function Description: There are two tables, a Business Unit table A (all the business unit information of a company in Table a), and the other table for user table B (in table B, where all users of a company are in the business Unit information), requiring the use of SQL statements to query the number of users in each department (note: When counting the number of users Need to count the users of all sub-dep
Wbk_goods_info where cop_g_no= ' 00078027 'There are only 1 records in the Wbk_goods_info table that meet this condition, and the entire data table has 100,000 records, so the selectivity of this query is 1/100000, which represents very high selectivity, so it is efficient to find data by index. Conversely, or your statement is as follows:Select * from Wbk_goods_info with (index (IDX_COP_G_NO)) where cop_g_no> ' 00018000 'At this time the matching
XML query in SQL SERVER: FOR XML specifies AUTO
Preface
In SQL SERVER, you can specify RAW, AUTO, EXPLICIT, and PATH for XML queries. This article uses some examples to introduce the XML query of AUTO in
The version of SQL Server is 2016, and you randomly try a query with a WHERE clause. As follows:Select * from wherelike'% system%'Na, how not to find out, clearly there should be several.Does SQL Server not support fuzzy queries? It's not possible, after all, it's version
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.