Snowflake Vs MS-SQL - Part 28 - CONCAT

   


CONCAT

Suppose you have a table and it is storing department ID as below. 

+-------------+------------+------------+---------------+
| EMPLOYEE_ID | LAST_NAME  | FIRST_NAME | DEPARTMENT_ID |
|-------------+------------+------------+---------------|
|         101 | Montgomery | Pat        |             1 |
|         102 | Levine     | Terry      |             2 |
|         103 | Comstock   | Dana       |             2 |
+-------------+------------+------------+---------------+

As per requirement, you want to display the department ID as Dept-1.

+-------------+------------+------------+---------------+
| EMPLOYEE_ID | LAST_NAME  | FIRST_NAME | DEPARTMENT_ID |
|-------------+------------+------------+---------------|
|         101 | Montgomery | Pat        | DEPT-1        |
|         102 | Levine     | Terry      | DEPT-2        |
|         103 | Comstock   | Dana       | DEPT-2        |
+-------------+------------+------------+---------------+

MS-SQL Server 

You can achieve this by using CONTACT or using the plus operator "+" as below:



In Snowflakewe can use a similar syntax for CONCAT as below:



However, Snowflake provides an alternative as REPLACE.  



For more details, you can refer to the following REPLACE or CONCAT





     

Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP