Posts

Showing posts from December, 2024

Snowflake Vs MS-SQL - Part 55 - POSITION

Image
                 POSITION If you want to search for a single character or group of characters in another string. ------------------------------------+------------+   Available_String                   | Position_1 | ------------------------------------+------------+   nevermore1 , nevermore2 , nevermore3 .|   1         |   -----------------------------------+------------+ In this case, we want to search " nevermore " in the string " nevermore1, nevermore2, nevermore3 .". It should return the position as 1. MS-SQL Server We can achieve this by using the  CHARINDEX()  as below. To get the second occurrence, we need to use the third parameter of CHARINDEX() as CHARINDEX('nevermore', province,5). In  Snowflake,  we can use a similar approach, which is  REGEXP_INSTR () .  This gives you the flexibility to find a second occurre...

Snowflake Vs MS-SQL - Part 54 - RANDOM

Image
                RANDOM Your table has many records and if you want to sort them randomly. MS-SQL Server   We can achieve this by using the NEWID() as below. In  Snowflake,  we can use a similar approach by using  RANDOM() .  For more details, you can refer to the following  RANDOM . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 53 - CONTAINS

Image
                CONTAINS If your table column has many records and you want to filter the data based on particular letter(s) consisting of. Eg. it should contain " tea " Actual Data: ------------+   DRINK_NAME | ------------+   coffee     |   ice tea    |   latte      |   tea        |  [ NULL ]     | ------------+ Expected Data: ------------+   DRINK_NAME | ------------+   tea        |   ice tea    | ------------+ MS-SQL Server   We can achieve this by using the LIKE operator as below. In  Snowflake,  we can use a similar approach as above.  However, Snowflake has an additional operator  CONTAINS .  For more details, you can refer to the following  CONTAINS . Yogesh Shinde LinkedInProfile <<< Back   Next >>>