SQL Server->> concat functions

Source: Internet
Author: User

This is a new function introduced after SQL Server 2012. function is like the meaning of its name. It is null-worthy to handle an empty string. Of course, it can do more than just support for characters. It supports n column input, and the column type support is more complete. However, its principle is simply to convert the incoming data into a nvarchar type using the CONVERT function. Don't believe you send an XML or sql_variant type of data in, you will see an error immediately. The error prompt is:

257  Level  - 3  *  from to nvarcharisn't useCONVERT function  to run this query.

At least my test results show that it is supported for int, FLOAT, DATETIME, nvarchar.

Test scripts

 withT as (SELECT TOP Ten CAST(Num as INT) asINT_FLD,CAST(Num as NVARCHAR) asSTR_FLD,CAST(Num as FLOAT) asFLT_FLD,CAST(NULL  as NVARCHAR) asNULL_FLD,CAST(Num as datetime) asdt_fld--CAST (Num as sql_variant) as VAR_FLD,--CAST (' <a>aa</a> ' as XML) as XML_FLD fromdbo. Numbers)SELECTCONCAT (INT_FLD,STR_FLD,FLT_FLD,NULL_FLD, DT_FLD) fromT

SQL Server->> concat functions

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.