Posts

Showing posts from June, 2024

Snowflake Vs MS-SQL - Part 22 - Dynamic Query Execution

Image
   Dynamic Query Execution During development, you may need to construct query dynamically and execute it. MS-SQL Server   You can use stored procedure to build dynamic query and then execute stored procedure by passing parameter value as below . In  Snowflake ,  we can achieve this by using table function  TO_QUERY . For more details, you can refer to the following  TO_QUERY   or  LINK . Yogesh Shinde LinkedInProfile <<< Back   Next >>>   

Snowflake Vs MS-SQL - Part 21 - DayName

Image
  Extract the DayName  If you want to extract dayname like Sunday, Monday from the date.  MS-SQL Server   You can use inbuilt SQL Functions  DATENAME . In  Snowflake ,  we can achieve this by using similar function DAYNAME . There is an alternative for the above code as below: For more details, you can refer to the following  LINK   or  LINK   . Yogesh Shinde LinkedInProfile <<< Back   Next >>>   

Snowflake Vs MS-SQL - Part 20 - Separate out Number from String

Image
  Separate out Number from String  Suppose you have an alphanumeric string(Yogesh2000) and if you want to separate out numbers. In this case, Yogesh & 2000 should get separated. MS-SQL Server   You can use inbuilt SQL Functions  Patindex  &  Substring . In  Snowflake ,  we can achieve this by using Regular Expression  REGEXP_SUBSTR . For more details, you can refer to the following  LINK . Yogesh Shinde LinkedInProfile <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 19 - ILIKE - Selecting all columns with names that match a pattern

Image
  ILIKE - Selecting all columns with names that match a pattern If you have a large table with many columns and when you want to select particular columns like all date columns to check the data. MS-SQL Server   You have to write a SELECT statement with specific columns as below. In  Snowflake ,   the above query works. Apart from this, we can use the keyword  ILIKE . It allows you to filter the columns based on wildcards as below : For more details, you can refer to the following  LINK . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 18 - Environment wise appearance

Image
  Environment-wise appearance If you have access to multiple environments like DEV, QA, UAT, or PROD then you have to take precautions while executing the query. If you don't take proper measures then you may end up with a lot of issues. MS-SQL Server   To take precautions, when you are executing a query SQL Server Management Studio you highlight the status bar by a different color. You can set green for DEV, Orange for UAT & RED for PROD. When you connect to these environments, you will get that indication which helps you take extra precautions. How to set different colors while connecting to the server: DEV PROD For more details, you can refer to the following  LINK . In  Snowflake ,   you can set the different environment-wise appearance as well. Suppose you are using DEV then you can set Light mode and when accessing  Non- DEV then you can go for Dark mode as below. For more details, you can refer to the following  LINK . Yogesh Shinde LinkedIn...

Snowflake Vs MS-SQL - Part 17 - Compare Data from Two Tables

Image
  Compare Data from Two Tables Sometimes you encounter a problem and must compare data from two tables. It is a hard and time-consuming task, but if you have a table with a comparable structure, the query will be simple . MS-SQL Server   There are several approaches: you can use JOIN and include all columns in the WHERE clause. Another option could be to concatenate all columns and then compare them.   For more details, you can refer to the following  LINK . A simple way is to write an  EXCEPT  query as below. In  Snowflake ,   the above EXCEPT query works. However, we can use the Aggregate Function HASH_AGG . It r eturns an aggregate signed 64-bit hash value. If you compare the return value of both tables as below: Not only this, if you want then you can compare the two columns as well. For more details, you can refer to the following  LINK . Yogesh Shinde LinkedInProfile <<< Back   Next >>>