SQL Learning Notes

Source: Internet
Author: User
Tags bulk insert

1 distince value can be used for column name Distince ID cannot be distince *

2 Time Function Day (getdate ()) Gets days year (GETDATE ()) Gets the month (GETDATE ()) months DateDiff (Day,getdate (), ' 2015-12-14 ') Gets the time difference, DateAdd plus DatePart Datename get part of time

3 stored procedures in the final or SQL statement assembly, for the frequently used data source with temporary table, you can be a temporary table as a temporary variable form,

Table TEMP Variable

4 Select
' INSERT into [dbo]. [Common_street] VALUES ('
+convert (varchar (), ID)
+ ', ' + streetname+ '
+ ', ' '
+ ', ' +convert (varchar), SUBSTRING (streetcode,0,7))
+ ', ' +convert (varchar (), IsDeleted)
+ ', ' + streetcode+ '
+ ', 0 '
+ ') '
From Tempstreet the use of stitching strings, write BULK INSERT statements, the main or the thinking limit

5 temporary table temporary variable temp table variable

6 stored procedure SET NOCOUNT on:

When SET NOCOUNT is on, no count is returned (indicating the number of rows affected by the Transact-SQL statement). When SET NOCOUNT is OFF, the count is returned.

If some of the statements contained in a stored procedure do not return much of the actual data, this setting can significantly improve performance because of the significant reduction in network traffic.
If some of the statements contained in a stored procedure do not return much of the actual data, this setting can significantly improve performance because of the significant reduction in network traffic.

SQL Learning Notes

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.