SQL Server 2008 New T-SQL shorthand syntax _mssql2008

Source: Internet
Author: User
1. You can assign values directly when you define a variable
DECLARE @Id int = 5
A 2.Insert statement inserts multiple rows of data at a time
INSERT into StateList VALUES (@Id, ' WA '), (@Id + 1, ' FL '), (@Id + 2, ' NY ')
3. Support + + operator
SET Stateid + 1
The complete example is as follows:
Copy Code code as follows:

CREATE TABLE statelist (stateid int, statename char (2))
Go
--Declare variable and assign a single statement
DECLARE @Id int = 5
--Insert multiple rows in a single statement with IDs 5, 6, and 7
INSERT into StateList VALUES (@Id, ' WA '), (@Id + 1, ' FL '), (@Id + 2, ' NY ')
--Use compound assignment operator to increment ID values to 6, 7, and 8
UPDATE StateList
SET Stateid + 1
--View The results
SELECT * from StateList

The result set is:

Stateid StateName
------- ---------
6 WA
7 FL
8 NY

(3 row (s) affected)
Related Article

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.