Exchange of rows and columnsCopy codeThe Code is as follows:Create table test (id int, name varchar (20), quarter int, profile int)Insert into test values (1, 'A', 1,1000)Insert into test values (1, 'A', 2,2000)Insert into test values (1, 'A', 3,4000
/***********************************Author: trieagle (to show you the shadow wall)Date: 2009.8.14Note: Reprinted please keep this information************************************/Use c # To construct the date data typeThe date type is not implemented
1. delete completely Repeated Records
Completely duplicated data is usually caused by the absence of primary key/unique key constraints.Test data:Copy codeThe Code is as follows:If OBJECT_ID ('duplicate _ all') is not nullDrop table
It is interesting to see a post on csdn about the SQL expression for drawing the Yang Hui triangle. Later, I thought about how to calculate C (n, m) = n according to the combination number calculation method of the Yang Hui triangle without using a
1. query all information of employees whose second letter is t orCopy codeThe Code is as follows:Select *From employeesWhere firstname like '_ [t, a] %'Note: In SQL, % indicates a string, so it cannot be annotated like matlab. The two double slashes
The extended attributes in SqlServer help are described as follows:The Extended Properties property sets or retrieves provider-specific connection information that cannot be explicitly described through the property mechanic.You can perform the
Many friends asked SQL server database "generate scripts" and exported only the SQL scripts of the database, while the data in the table is still not exported. It is very simple. Take a look at the Tutorial:
Note: I use SQLServer2008 here. Other
Recently, we need to do some research on SQL query performance improvement, so we have studied the SQL statement solution process. I read it in the garden and wrote many related articles, with different focuses. This article is summarized on the
Error message: MSSQLSERVERSQLServerAgent cocould not be started (reason: SQLServerAgent must be able to connect to SQLServer as SysAdmin, but "(unknown)" is not a member of the SysAdmin role ).Running Environment: Windows2003R2 32bit + MSSQL2005 +
If you have a string such as "sun, star, moon, clouds", you want to use the given separator ', 'How can we break this string into [sun] [star] [moon] [clouds] elements? Create a Function with the following code:Copy codeThe Code is as follows:Create
In the select statement, you can use the groupby clause to divide rows into smaller groups. Then, use the grouping function to return the summary information of each group. In addition, you can use the having clause to limit the returned result set.
In view of the serious shortage of manpower (the resources of two and a half persons were counted at that time), the idea of Manually changing databases one by one was dispelled. The current program structure does not allow revolutionary practices,
Copy codeThe Code is as follows:/*-- Note: Prepare data (skip this step, which is time consuming)Create table CHECK1_T1(Id int,C1 CHAR (8000))Create table CHECK1_T2(Id int,C1 CHAR (8000))DECLARE @ I INTSET @ I = 1While I BEGINInsert into CHECK1_T1
Insert into (column name) select column name from table name where condition -- do not create a table, only copy table dataSelect column name into Table Name (this table name does not exist) from table name where condition, -- create a new table,
Introduction
In SQL SERVER, the storage method of the database on the hard disk is no different from that of the common files in Windows, just a few files. SQL SERVER manages files by managing logical file groups. understanding the concepts of files
First, create a Database Project in VSTS and add a class to implement the following method:Copy codeThe Code is as follows:/// /// Regs the ex match./// /// The input value. /// The regex pattern. /// Author: Petter Liu
/* Ranking of increase/decrease */Copy codeThe Code is as follows:Select top 50 UserName, sum (ReceivePrice)-sum (GuessPrice) as ReceivePrice,Cast (sum (case when ReceivePrice> 0 THEN 1.0 ELSE 0 END)/count (ReceivePrice) * 100 as numeric () as
Copy codeThe Code is as follows:. Cursor Mode 1 DECLARE @ Data NVARCHAR (max)SET @ Data = '1, tanw; 2, keenboy '-- Id, NameDECLARE @ dataItem NVARCHAR (100)DECLARE data_cursor cursor for (SELECT * FROM split (@ Data ,';'))OPEN data_cursorFetch next
That's all.The stored procedure calls mup_GetA (I erased the project-related names)You can view objects dependent on mup_GetA through the functions provided by sqlserver graphics manager.The result is a bit confusing. I didn't list mup_GetB (I used
What is parameterized query?A simple way to understand parameterized queries is to think of it as just a T-SQL query that accepts parameters that control what the query returns. By using different parameters, a parameterized query returns different
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.