Simple and useful SQL scripts (transpose columns and querying the same records in a table)

id3

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

Use c # To construct the date data type

/***********************************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

How to delete duplicate data using SQL statements

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

Introduction to the implementation method of drawing the Yang Hui triangle using SQL

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

SQL Server query statement usage

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

SQL Server extended attributes

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

SQL Server export SQL file/table Architecture and Data operation steps

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

Detailed summary of the keyword parsing process of SQL statements

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

Solution to SQL Server proxy service failure

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 +

SQL statement to break down strings based on specified delimiters

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

Difference between having and where in SQL

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.

SQL Server Index optimization tool

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,

Checklist Summary of SQL statements

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

Usage instructions for insert select and select

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,

Storage Methods, files, and file groups of database files in SQLServer

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

Use regular expression functions in T-SQL

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

SQL statement Summary of various World Cup conjecture lists

/* 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

Two solutions for SQL server batch insert and update

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

SQL Server searches for all stored procedures that contain a specific text.

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

SQL Server parameterized query Experience Sharing

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

Total Pages: 923 1 .... 471 472 473 474 475 .... 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.