Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
406 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Some other pages relevant to these blogs include:
You can also book hourly online consultancy for your time zone with one of our 7 expert trainers!
|
How does Snowflake compare to Microsoft's T-SQL for SQL Server? Part four of a five-part series of blogs |
|---|
|
All dialects of SQL are similar, you'd think, but the different ethos and editing environment of Snowflake versus SQL Server make the switch surprisingly difficult, as this blog explains.
|
In this blog
So this is the difference in Snowflake which I initially found hard to believe. To explain the difference, let's first look at how things work in SQL Server.
In SSMS you can visually show the relationship between two tables using a database diagram:

This shows that each author can have many corresponding books (which makes sense).
SSMS is able to create and enforce relationships because tables have one field which is the primary key:

The key symbol next to the AuthorId column shows that it's impossible to have two authors in our databse with the same author id.
SQL Server will always enforce referential integrity (ie ensure that data obeys relationships between tables) and primary keys, so it's impossible to get mismatched data if your database is correctly designed.
Unbelievably (at least to this SQL Server user) Snowflake has no concept of a primary key or a relationship. So although we know that there's a link between these two tables, Snowflake doesn't:

This is the Author table in Snowflake.

This is the Book table.
Of course, this doesn't stop you joining the two tables together:
SELECT
-- join each author's first and last name
a.FirstName || ' ' || a.LastName AS Author,
b.Title
FROM
Author AS a
JOIN Book AS b ON a.AuthorId = b.BookId
Snowflake assumes that the place from which you are getting data is robust. You can ingest data (the Snowflake word for extracting and loading) from many different sources:

Some of the places from which you can import data.
However, it's the providers of data who are responsible for ensuring that you don't have any duplicate key fields or invalid relationship data.
One implication of all of the above is that you have to be very careful when adding data, to ensure you don't violate the constraints which you know are there (but Snowflake doesn't). Here for example is an excerpt from some code to merge some books safely into our database:
-- after doing an insert you typically have to check 2 possible cases
-- case 1: the records you're inserting match existing data, in
-- which case we update the existing rows
WHEN MATCHED AND (
tgt.AuthorId IS DISTINCT FROM src.AuthorId
OR tgt.Title IS DISTINCT FROM src.Title
) THEN
UPDATE SET
AuthorId = src.AuthorId,
Title = src.Title
-- case 2: there is no match, so we can insert the rows
WHEN NOT MATCHED THEN
INSERT (BookId, AuthorId, Title)
VALUES (src.BookId, src.AuthorId, src.Title);
All of this sends a shiver down my spine, but it's a necessary consequence of the way the Snowflake database is built.
| Parts of this blog |
|---|
|
Some other pages relevant to these blogs include:
You can also book hourly online consultancy for your time zone with one of our 7 expert trainers!
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2026. All Rights Reserved.