CONCAT – New String Function in SQL Server 2012

CONCAT is a new String function introduced in SQL Server 2012. This function returns an output which is a concatenated string value of the argument values passed in the function. The function would need a minimum of 2 values to be passed.

Let’s take a look at the function. In order to use this function, we shall first create a table and insert few records. The following script is used to the task of creating a table and inserting the data into that table.

CREATE TABLE [dbo].[Customer_Address](
 [CustomerID] [bigint] NULL,
 [Address1] [varchar](50) NULL,
 [Address2] [varchar](50) NULL,
 [ZipCode1] [char](5) NULL,
 [ZipCode2] [char](4) NULL

INSERT INTO Customer_Address
(1,'#1','Moon Walk Drive', 24578,2881 ),
(2,'#2','Roof Top Lane', 54856,5421 ),
(3,'#3','Full Thottle Blvd', 90425,5782 ),
(4,'#4','Drive Slow Road', 18854,6502 )

First let us look at the data in the table by doing a Select * on the table. The pic below displays the result set.

Now let us run the following query which uses the CONCAT function to concatenate the Address1 ad Address2 columns as a single column and also concatenate the 5 character length ZipCode1 and 4 character length Zipcode2 and display a single column output. Note that I am going to use a space ‘ ‘, and a hyphen ‘-‘ in order to display the concatenated column in a meaningful way.

SELECT CustomerID, CONCAT(Address1,' ',Address2) AS Address,
CONCAT(ZipCode1,'-',ZipCode2) AS ZIP
FROM Customer_Address

The below picture shows the result of the query we have just executed.

In previous Versions of SQL Server, you could concatenate string values using a +. If order to achieve the same result you can write the following code.

SELECT CustomerID, Address1 + ' ' + Address2 AS Address,
ZipCode1 + '-' + ZipCode2 AS ZIP
FROM Customer_Address

Do you like this site? Like our FB page @\LearnSQLWithBru so that, you know when there is a new blog post.

— Bru Medishetty

How to uninstall SQL Server 2012?

This blog is actually in response to comments to one of my previous blogs Installing SQL Server 2012 Release Candidate 0 posted earlier this week. The user asked the steps to uninstall SQL Server 2012 RC 0, so I thought to write a short blog to help others also, who are looking for steps to uninstall SQL Server 2012, for that matter the steps to uninstall other versions like SQL Server 2008 R2 and 2008 are also very similar to the steps in this blog..

So let us look at the steps to uninstall SQL Server 2012. 

On the machine where SQL Server 2012 is installed (in my case it is Windows Server 2008 R2) clicks Start and select Control Panel.

When control panel is displayed, under Programs section, click Uninstall a program.

Then the list of programs and features installed on that machine is displayed as below.

Click on Microsoft SQL Server 2012 RC0 (as mentioned earlier, if you are trying to uninstall SQL Server 2008 or 2008 R2, choose that Version).  A small window similar to the SQL Server Installation splash screen is displayed.

Click on Remove and you should see Setup Support Rules windows displayed which is displayed below.

Click OK to proceed. In the next screen Select Instance screen, choose what you want to uninstall from that machine. There will be a drop down displayed from which we need to select the Instance which we want to uninstall now. If there are multiple Instances on that machine, you would need to be careful in choosing which Instance to uninstall. Also, the list of Instances and their Versions (if there are multiple instances) will be displayed in the a grid below for an overall summary of what are on that machine. Once you choose your SQL Server Instance click Next. In the next window (pic below) select the features that you want to install from the machine. Since I wanted to show the steps to uninstall the entire SQL Server 2012 setup, I selected all features. If your machine has other Versions of SQL Server like SQL 2008 or 2008 R2, some of these components should not be uninstalled.

Click Next to proceed.

Then, there are some removal checks that are done to make sure the uninstall will run smoothly. If there are no failures, click Next.

Click Remove to start the uninstall process of SQL Server 2012. You should be seeing the progress window of the SQL Server uninstall. Once the process is completed, there should be a final screen saying that SQL Server is uninstalled. I did not uninstall the SQL Server as I would need it to work on, so I have not shown those 2 screenshots..

Do you like this site? Like our FB page @\LearnSQLWithBru so that, you know when there is a new blog post.

— Bru Medishetty

Startup Parameters Tabs in Configuration Manager – New feature in SQL Server 2012

With each new SQL Server Version, plenty of new features and enhancements are released. In SQL Server 2012, one of those new additions is the Startup Parameters Tab in SQL Server Configuration Manager. Using this you can make changes to SQL Server startup parameters. 

Let us learn where to find the newly added tab.

On the machine where SQL Server 2012 is installed, go to Programs and Microsoft SQL Server 2012 (in this case this RC0, but in the final version Release to Market Version, you would see only Microsoft SQL Server 2012). Then click on Configuration Tools to expand that node, you should see SQL Server Configuration Manager, click to open. (Pic below)

You should see a console which has 2 sections, on the left hand side click services upon which the SQL Server components that are installed on that machine are displayed as shown below. Right click on the Service SQL Server and select Properties.

The Properties window is displayed and there are 6 tabs in total. Click on Startup Parameters Tab to bring it to front. (pic below)

You can see the current startup parameters in this Tab and add new one if required.

Do you like this site? Like our FB page @\LearnSQLWithBru so that, you know when there is a new blog post.

— Bru Medishetty