SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SQL Server 2012 Download and T-SQL Tutorials
Development resources, articles, tutorials, code samples and tools and downloads for ASP.Net, SQL Server, R Script, Windows, Windows Phone, AWS, SAP HANA and ABAP, like SAP UI5, Screen Personas, etc.

Install SQL Server 2019
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014

Surround With Feature New in SQL Server 2012

One of new features of SQL Server 2012 is Surround With feature in Microsoft SQL Server Management Studio (SSMS). New "Surround With" enhancement in SSMS Query Editor screen makes it easier to code and edit T-SQL in the Query Editor screen for sql developers.

SQL Server Management Studio Surround With improvement enables T-SQL programmers to enclose a block of sql script with IF conditional statement, WHILE loop block or with BEGIN END blocks.

Here is a demonstration of the Surround With enhancement in programmability in SQL Server Management Studio of new SQL Server 2012.

Highlight the sql script or lines of T-SQL code block that you want to surround with one of the block statements and then right-click.

Surround With in SQL Server Management Studio query editor

From the displayed context menu, select Surround With... option.
The short list of possible enclose options will be displayed for your choice.

Code snippet for Begin...End block.
Code snippet for If construct.
Code snippet for While loop.

TSQL script Surround With begin if while code snippet in SQL Server 2012

The condition to evaluate is in different color and the cursor is highlighting the condition.

sql code snippet for while loop in SQL Server 2012

Code snippet for Begin and End block.

code snippet for begin end block in SQL Server 2012 SSMS

Code snippet for If construct.

Surround With code snippet for if construct in SQL Server 2012

--From the list of options available in the Surround With drop down list, select the appropriate option/construct in which you want your code selected in first step to be enclosed.
--This will enclose the selected code snippet (in step 1) into the selected construct (in step 2) as shown below

SQL Server Resources

SQL Server Articles

SQL Server 2012

SQL Server Tools

SQL Blog

MS SQL Server Forums

Copyright © 2004 - 2020 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems