Posts

Snowflake Vs MS-SQL - Part 79 - Adding a comment to the Column of a Table

Image
            Adding a comment to the Column of a Table Suppose you are designing a new table, and you want to add a comment for the columns of that table, so that whoever uses this table will get some idea of the columns of this table. MS-SQL Server   We can achieve it by using a system-level stored procedure( sp_addExtendedProperty ), which uses Extended properties to allow you to store custom metadata: In  Snowflake,  we can use a similar approach by using the  COMMENT  clause as  below: For more details, refer to  COMMENT . Yogesh Shinde LinkedInProfile <<< Back   Next >>>   

Snowflake Vs MS-SQL - Part 78 - Duplicate Rows Identification - Group By ALL

Image
         Duplicate Rows Identification – Group By ALL If you want to identify total identical rows (i.e., all column values are the same) from a table. MS-SQL Server   We can achieve the above-expected result by any one of the approaches below: In  Snowflake,  we can use all the above queries; however, we can use   GROUP BY ALL  as below. This is more beneficial when the table has so many columns; you don't need to mention all columns in the GROUP BY clause. For more details, you can refer to the following:  GROUP_BY_ALL . Yogesh Shinde LinkedInProfile <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 77 - Remove Duplicates From String

Image
           Remove Duplicates From String Suppose you have a string that contains values separated by a delimiter, and you have to remove those duplicates. -- Actual String 'A, B, C, a, b' -- Expected String 'A, B, C' MS-SQL Server   We can achieve it by using functions like  STRING_AGG & STRING_SPLIT : In  Snowflake,  we can use a similar approach by using  LISTAGG & SPLIT_TO_TABLE,  as below For more details, refer to  LISTAGG  &  SPLIT_TO_TABLE . Yogesh Shinde LinkedInProfile <<< Back   Next >>>   

Snowflake Vs MS-SQL - Part 76 - COLLATE - Comparing Text Strings

Image
           COLLATE - Comparing Text Strings Suppose you want to compare the string using case sensitivity. When  comparing " HELLO " with " hello ", it should not  match. MS-SQL Server    We can achieve it by using different collation SQL_LATIN1_GENERAL_CP1_CS_AS : However, in  Snowflake,  we can use a similar approach by using  COLLATE,  as below: Note: CS used here for case-sensitive. For case-insensitive, you can use CI. For more details, you can refer:  COLLATE . Yogesh Shinde LinkedInProfile <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 75 - String Length and Trimmed Length

Image
           String Length and Trimmed Length Suppose you want to calculate the length of a string that contains trailing spaces. MS-SQL Server   We can achieve it by using functions like LEN & DATALENGTH : However, in  Snowflake,  we can use two functions,  LENGTH & RTRIMMED_LENGTH,  as below: For more details,  refer to  LENGTH  &  RTRIMMED_LENGTH . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 74 - Convert Column Into Comma Separated

Image
          Convert Column Into Comma-Separated If you have data in a table and you want to convert columnar data into a comma-separated string. Current Data: Expected Data: MS-SQL Server   We can achieve it by anyone approaching below: However, in  Snowflake,  we can use two ARRAY functions,  ARRAY_AGG & ARRAY_TO_STRING,  as below: For more details, you can refer to:  ARRAY_AGG  &  ARRAY_TO_STRING . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 73 - First Coming Sunday

Image
          First Coming Sunday Sometimes you have to calculate first for the coming Sunday. You must use that date for further calculations or filtering. MS-SQL Server   We can achieve this as follows: In  Snowflake,  we can use a similar approach  as below.  For more details, you can refer to the following:  NEXT_DAY . Yogesh Shinde LinkedInProfile <<< Back   Next >>>