SQLServer 2008 新增T-SQL 簡寫語法
更新時間:2009年07月15日 00:37:32 作者:
SQLServer 2008 新增T-SQL 簡寫語法
1.定義變量時可以直接賦值
DECLARE @Id int = 5
2.Insert 語句可以一次插入多行數(shù)據(jù)
INSERT INTO StateList VALUES(@Id, 'WA'), (@Id + 1, 'FL'), (@Id + 2, 'NY')
3.支持+=操作符
SET StateId += 1
完整示例如下:
CREATE TABLE StateList(StateId int, StateName char(2))
GO
-- Declare variable and assign a value in 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
結(jié)果集為:
StateId StateName
------- ---------
6 WA
7 FL
8 NY
(3 row(s) affected)
DECLARE @Id int = 5
2.Insert 語句可以一次插入多行數(shù)據(jù)
INSERT INTO StateList VALUES(@Id, 'WA'), (@Id + 1, 'FL'), (@Id + 2, 'NY')
3.支持+=操作符
SET StateId += 1
完整示例如下:
復(fù)制代碼 代碼如下:
CREATE TABLE StateList(StateId int, StateName char(2))
GO
-- Declare variable and assign a value in 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
結(jié)果集為:
StateId StateName
------- ---------
6 WA
7 FL
8 NY
(3 row(s) affected)
相關(guān)文章
Microsoft SQL Server 2008 基本安裝說明
這篇文章主要介紹了Microsoft SQL Server 2008 基本安裝說明 ,需要的朋友可以參考下2015-08-08SQL server 2008 數(shù)據(jù)庫優(yōu)化常用腳本
這篇文章主要介紹了SQL server 2008 數(shù)據(jù)庫優(yōu)化常用腳本,需要的朋友可以參考下2015-10-10SQL Server 2008中SQL查詢語句字段值不區(qū)分大小寫的問題解決
這篇文章主要介紹了關(guān)于SQL Server 2008中SQL查詢語句字段值不區(qū)分大小寫問題的解決方法,文中將解決方法介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。2017-07-07SQL Server 2008 Express如何開啟遠(yuǎn)程訪問
這篇文章主要介紹了SQL Server 2008 Express 遠(yuǎn)程訪問的設(shè)置方法,需要的朋友可以參考下2015-10-10SQL Server 2008 備份數(shù)據(jù)庫、還原數(shù)據(jù)庫的方法
這篇文章主要介紹了SQL Server 2008 備份數(shù)據(jù)庫、還原數(shù)據(jù)庫的方法,需要的朋友可以參考下2014-08-08SQL Server使用一個語句塊批量插入多條記錄的三種方法
本文介紹了三種不同的方法向數(shù)據(jù)庫中一次插入多條記錄的方法,第三種方法是SQL Server2008中特有的,大家體驗(yàn)一下吧。2016-05-05SQL SERVER 2008 CTE生成結(jié)點(diǎn)的FullPath
SQL SERVER 2008 使用CTE是經(jīng)常的事兒,有時我們想存儲一些冗余數(shù)據(jù),像每個結(jié)點(diǎn)的FullPath。2011-10-10