Is there any way/use of putting pipe symbol ||
in select
clause.
I have come across following query in one of the article(probably to concatenate two values), but when I try to use the same in my query I am getting syntax error.
select FirstName ||''|| LastName As CustomerName from Customer
Please correct if I am using wrong syntax.
Pipe Character (|) is the Bitwise OR Operator in T-SQL The pipe character (|) is the bitwise OR operator. The query below produces the truth table for OR operations between the AttributeA and AttributeB columns. The LogicalOR will be 1 if any either AttributeA or AttributeB equals 1.
The concatenation operator is a binary operator, whose syntax is shown in the general diagram for an SQL Expression. You can use the concatenation operator ( || ) to concatenate two expressions that evaluate to character data types or to numeric data types.
The || operator is used for concatenating two strings, in Oracle a single | is not a valid operator.
The SQL || operator allows you to concatenate 2 or more strings together.
You can use CONCAT()
function, which works in SQL Server 2012 and above, or just a plain +
sign to do concatenation.
https://msdn.microsoft.com/en-us/library/hh231515(v=sql.110).aspx
Returns a string that is the result of concatenating two or more string values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With