SQL Server 2008 Express Concat() Doesn't Exist

SQL Server 2008 Express CONCAT() doesn't exist?

Maybe something like,

SELECT DISTINCT id1, id2, id1 + ', ' + id2

would that work?

How do I use the CONCAT function in SQL Server 2008 R2?

CONCAT is new to SQL Server 2012. The link you gave makes this clear, it is not a function on Previous Versions, including 2008 R2.

That it is part of SQL Server 2012 can be seen in the document tree:

SQL Server 2012  
Product Documentation
Books Online for SQL Server 2012
Database Engine
Transact-SQL Reference (Database Engine)
Built-in Functions (Transact-SQL)
String Functions (Transact-SQL)

EDIT Martin Smith helpfully points out that SQL Server provides an implementation of ODBC's CONCAT function.

How can i do a concat() in SQL 2008

CONCAT(a,b,c) is basically just syntactic sugar for COALESCE(RTRIM(a),'') + COALESCE(RTRIM(b),'') + COALESCE(RTRIM(c),'') (example).

So:

REPLACE
(
CONCAT
(
NOM_TIPO_QUEBRA_ORDEM, CHAR(13),
DSC_TIPO_QUEBRA_ORDEM, CHAR(13),
HST_ORDEM_FILA_MOVIMENTO
),
CHAR(13) + CHAR(13), '') as justificativa_quebra

Becomes:

REPLACE(
COALESCE(RTRIM(NOM_TIPO_QUEBRA_ORDEM),'') + char(13)
+ COALESCE(RTRIM(DSC_TIPO_QUEBRA_ORDEM),'') + char(13)
+ COALESCE(RTRIM(HST_ORDEM_FILA_MOVIMENTO), ''),
CHAR(13) + CHAR(13), '') as justificativa_quebra

Next, send some feedback up the chain that using a database platform so famously out of support is just not a great idea.

More than 2 columns in a CONCAT function

There must be an error somewhere else in your view!!

Ok, then what I did with your code was to change this line

{ fn CONCAT('T.a.v. ', C.Salutation + ' ', C.FirstName + ' ', C.MiddleName + ' ', C.LastName) } AS 'T.a.v.'

to this

CONCAT('T.a.v. ', C.Salutation + ' ', C.FirstName + ' ', C.MiddleName + ' ', C.LastName) AS 'T.a.v.'

Edit:

Just to explain the difference in code, is that the one with { fn ....} is a Canonical function and microsoft promise that it will work on all ODBC connections.

From MSDN:

Canonical functions are functions that are supported by all data providers, and can be used by all querying technologies. Canonical functions cannot be extended by a provider.

Remove concat and IIF function for SQL Server 2008

The existing condition succeeds if @Filter is not the empty string or if group_id belongs to a CSV list that is stored in @Filter.

I would express this with OR and LIKE; I find that it is easier to understand the intent this way without using charindex() (but that's also a matter of taste):

WHERE
@Filter = ''
OR ',' + @Filter + ',' LIKE '%,' + convert(varchar(100),Group_ID) +',%',

Concatenating int and nvarchar column in TSQL

are you sure the error is related to the casts and not to the where conditions?
check that the column types are matching

CONCAT' is not a recognized built-in function name. Update transaction with Inner Join

Why not simply concatenate using +

UPDATE O
SET O.COD_MODEL_ORDER = M.COD_MODEL + '-' + O.COD_ORDER
FROM ORDER O
INNER JOIN MODEL M ON M.ID_MODEL = O.ID_MODEL
WHERE ID_ORDER = 5;

Manage hierarchical data error :REPEAT' is not a recognized built-in function name.

You using code from a MySQL article on MS SQL Server.

Much will translate fine, but much won't. As @FilipDeVos says, the equivilent to REPEAT() in SQL Server is REPLICATE(), and you're going to find many more cases like this.

When you find them, you need to search on line for the SQL Server equivilent to the MySQL statements that you are using.


As for different methods of managing hierarchies, the most common is probably adjaceny-lists, then nested-sets that you're using in that article. It depends on your needs, keep researching, there is no universall golden answer.

EDIT

If you keep going through that article and ask here about every difference, you'll be here forever. You need to search the web for your answers ;)

But, for now, after your added question about CONCAT(), try this...

SELECT REPLICATE(' ', COUNT(parent.name) - 1) + node.name AS name 


Related Topics



Leave a reply



Submit