Snowflake Cross Database Access, Syntax and Examples

The cross database access does allows you to access the objects such as tables, view, synonyms, functions that are available on the same cloud warehouse server. In this article, we will check Snowflake cross database access and it's restrictions. Snowflake Cross Database Access Using cross database access method, you can refer the object present in another database. For example, you can refer function present in another database and use result in the current database. select demo_db..isnumeric(to_variant('hello')) is_numeric; +------------+ | IS_NUMERIC | |------------| | False | +------------+ You can use cross…

Continue ReadingSnowflake Cross Database Access, Syntax and Examples
Comments Off on Snowflake Cross Database Access, Syntax and Examples

Snowflake User Defined Functions, Syntax and Examples

An UDF evaluates an arbitrary SQL expression and returns the result(s) of the expression. Snowflake supports creating user defined function. You can create custom user-defined functions (UDF) using either SQL statements or Java script program. In this article, we will check Snowflake user defined functions, types, syntax, examples and how to create them. Snowflake User Defined Functions The custom user defined functions are bound to the database. But, fortunately, Snowflake supports cross database access. You can create custom user defined functions in one centralized database and access from all other databases.…

Continue ReadingSnowflake User Defined Functions, Syntax and Examples
Comments Off on Snowflake User Defined Functions, Syntax and Examples

Snowflake isnumeric Alternative and Examples

The data warehouse combines the data from various sources. Sometimes, data will be corrupted or erroneous values are introduced. For example, you may need to filter out non-numeric values from the salary field. In this article, we will check what is the isnumeric function alternative available in Snowflake. We will also check methods that you can use to validate data or expression. Snowflake isnumeric Function Alternative In a relational database such as SQL Server, isnumeric function is available as a built-in numeric function. But, as of now, Snowflake does not…

Continue ReadingSnowflake isnumeric Alternative and Examples
Comments Off on Snowflake isnumeric Alternative and Examples

Snowflake DECODE Function Syntax and Examples

Snowflake cloud data warehouse supports the DECODE function which is similar to other relational databases such as Redhift, Netezza, Oracle, SQL Server, etc. The DECODE function is used to implement simple case statements. i.e. you can use it to implement simple if-then-else statement. This command is similar to the Snowflake CASE statement. Snowflake SQL DECODE Function The DECODE function compares the select expression to each search expression in order. As soon as a search expression matches the selection expression, the corresponding result expression is returned. Snowflake SQL DECODE Function Syntax…

Continue ReadingSnowflake DECODE Function Syntax and Examples
Comments Off on Snowflake DECODE Function Syntax and Examples

Difference Between Snowflake Stored Procedure and UDFs – SP vs UDFs

You can use both stored procedure and user defined functions to encapsulate the business logic and achieve specific tasks. However, there are important differences between UDFs and stored procedures. In this article, we will check the difference between Snowflake stored Procedure and user defined functions (UDFs). Difference Between Snowflake Stored Procedure and UDFs The Snowflake stored procedure vs user defined function is an interesting comparison. Both are used to achieve certain functionalities that are not possible using built-in functions available in Snowflake. Following are some import comparison between Snowflake stored…

Continue ReadingDifference Between Snowflake Stored Procedure and UDFs – SP vs UDFs
Comments Off on Difference Between Snowflake Stored Procedure and UDFs – SP vs UDFs

Snowflake Transaction Management – BEGIN, COMMIT, ROLLBACK

In a Snowflake, a transaction is a set of SQL statements, both reads and writes on database objects, that are processed as a unit. All the statements in the transaction are either committed or undone using rolled back as a single unit. Similar to other databases such as Redshift, Netezza, etc, Snowflake transactions guarantees ACID properties. In this article, we will discuss about the Snowflake transaction management using BEGIN, COMMIT and ROLLBACK. Snowflake Transaction Management The default automatic commit behavior of the Snowflake database causes each SQL command that runs…

Continue ReadingSnowflake Transaction Management – BEGIN, COMMIT, ROLLBACK
Comments Off on Snowflake Transaction Management – BEGIN, COMMIT, ROLLBACK

Commonly used Snowflake Date Functions and Examples

The date functions are most commonly used functions in the data warehouse. You can use date functions to manipulate the date expressions or variables containing date and time value. For example, get the current date, subtract date values, etc. In this article, we will check what are commonly used date functions in the Snowflake cloud data warehouse. Many applications use date functions to manipulate the date and time data types. Each date value contains the century, year, month, day, hour, minute, second and milliseconds. Hence, date types are highly formatted…

Continue ReadingCommonly used Snowflake Date Functions and Examples
Comments Off on Commonly used Snowflake Date Functions and Examples

Snowflake Interval Data Types and Conversion Examples

The INTERVAL data types in Snowflake are handy and widely used types when working with date, time variables. Snowflake supports interval types in the same way as other PostgreSQL databases such as Netezza, Redshift, Vertica, Oracle, etc. In this article, we will check interval types with some common use cases. Snowflake Interval Data Types You can express interval types as a combination of the INTERVAL keyword with a numeric quantity and a supported date part; for example: INTERVAL '1 days' or INTERVAL '10 minutes'. The Snowflake INTERVAL functions are commonly…

Continue ReadingSnowflake Interval Data Types and Conversion Examples
Comments Off on Snowflake Interval Data Types and Conversion Examples

Snowflake Reuse Computed column – Derived Columns

The derived columns in Snowflake are columns that are derived from the previously calculated columns in same SELECT statement. In this article, we will check how to reuse previously computed or calculated column in Snowflake. These kind of columns are sometime called lateral column alias. What are derived columns? Derived columns or computed columns are virtual columns that are not physically stored in the table. Their values are re-calculated every time they are referenced in a query. In other word, Derived columns are columns that you derive from other previously…

Continue ReadingSnowflake Reuse Computed column – Derived Columns
Comments Off on Snowflake Reuse Computed column – Derived Columns

Snowflake Split String on Delimiter-Functions and Examples

The split string is one of the common requirements in many relational database and programming languages. For example, get username from the string. Many RDBMS provides the functions or methods to split string on a delimiter and extract required text from an array. In this article, we will check Snowflake functions to split string on a delimiter. Snowflake Split String In many relational databases such as Netezza, PostgreSQL, etc, you can use array functions to extract records from split string result. But, Snowflake supports many useful split functions that you…

Continue ReadingSnowflake Split String on Delimiter-Functions and Examples
Comments Off on Snowflake Split String on Delimiter-Functions and Examples