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
Inner Join with Count() on Three Tables
Oracle Db: How to Write Query Ignoring Case
Creating a Composite Foreign Key in SQL Server 2008
Can the "In" Operator Use Like-Wildcards (%) in Oracle
Querying More Than 65536 Rows Error in Excel 2013
Spring Boot Query Annotation with Nativequery Doesn't Work in Postgresql
There Is Already an Object Named '#Columntable' in the Database
Combining Rows of Queried Results by Unique Identifier
How to Convert Timestamp with Milliseconds to Date in Oracle
Instead of Null How to Show '0' in Result with Select Statement SQL
Possible to Restore a Backup of SQL Server 2014 on SQL Server 2012
How to Find the Number of Occurrences of a Particular Character in a String Using SQL
Oracle SQL - Sum and Group Data by Week
How to Create Birt Report Based on Multiple Data Sets
Run Stored Procedure and Return Values from Vba
With Hibernate, How to Query a Table and Return a Hashmap with Key Value Pair Id>Name