T-SQL TIP in SQL Server 2008
You love this if you write a lot of T-SQL code. This tip I can say as T-SQL language syntax enhancement. The following are the enhancements in T-SQL
- Now We can declare and initialize the variables with single statement.

2. Compound assignment operators are supported.
3. You can build multiple lines data inline with Row Constructors.
Examples:
Variable Assignment
CREATE TABLE EMP(EMPId int, EMPName varchar(150)) GO -- Declare variable and assign a value in a single statement DECLARE @EMPId int = 5
Compound Assignment Operator
-- Use compound assignment operator to increment ID values -- to 6, 7, and 8 UPDATE EMP SET EMPId += 1
Row Constructors
-- Insert multiple rows in a single statement with --IDs 5, 6, and 7 DECLARE @EMPID int = 5; INSERT INTO EMP VALUES(@EMPId, 'Nick'), (@EmpId + 1, 'David'), (@EmpId + 2, 'Major')
| Share this post : |
Related Posts:
More from kalyan
- Host the WCF Service in IIS
- PIVOT & UNPIVOT Operators in SQL Server 2008
- Creating an Analysis Services Project in Visual Studio 2008
- MERGE Statement in SQL Server 2008
- SSIS Package Configuration in SQL server 2008
kalyan Recommends
No comments yet. Be the first.
Leave a reply
![Recommend [kalyanms1]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)