Posts

Showing posts from March, 2024

Snowflake Vs MS-SQL - Part 4 - Truncate and Insert

Image
     Truncate and Insert    MS-SQL Server   Suppose if you want to Insert new set of data in a table and prior to that if you want to remove all records then you can achieve this in two steps. 1. First Truncate/Delete all records from the table. 2. Insert new records into the table. However in  Snowflake  we can achieve this in single step. Insert statement is having an optional parameter OVERWRITE . This parameter specifies that the target table should be truncated before inserting the values into the table. For more details, you can refer the following  LINK . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 3

Image
    Temporary Tables    MS-SQL Server   When you create temporary table, you can NOT create with same name as that of main table. In SQL, you have to use # or ## to create temporary table. However  Snowflake  does allow to create temporary table with same name as that of main table. Consider you have a table "Main_Table" under DEV schema say with 1000 records and if you create temporary table without records then temporary table gets created. When you fire a select query as below, it returns zero records. This means it pulls the records from newly created temporary table and not from the main table. If you create a view on this newly created temp table and fire select statement on the view then you  get zero records. If you move to different session/worksheet and fire select statement on view then you get actual count of the table. Because temporary table's scope is for a particular session. And finally, when you drop this table, temporary table g...

Snowflake Vs MS-SQL - Part 2

Image
   Trailing Comma in Select Statement   MS-SQL Server  does NOT support trailing Comma in SELECT Statement. If you try to run the query with trailing comma at the end, then you may get an error like " Incorrect syntax near the keyword 'from'. " However Snowflake  does support trailing Comma in SELECT Statement. If you try to run the above query with trailing comma at the end, it will NOT throw an error and will pull result. You can read more about this at  Trailing_Comma_Select  Yogesh Shinde LinkedInProfile <<< Back   Next >>>