Add dummy rows to a table to enforce primary/foreign key constraint

No Comments

Sometimes the data is not what you want it to be. Or rather the quality is not what you want it to be. What I am referring to in this case is when you have a primary key and you want to reference that key from another table by a foreign key constraint but for some reason the foreign key is NULL and you don’t want NULL as a primary key in that table. Sure you can add a dummy row manually to your table with a value of '-1' or whatever you like. But what if you TRUNCATE your table before each load? Should you add the row manually every time? I’m sure that there’s hundreds of solutions  to this problem but below is how I choose to solve my particular problem. 

Read More…

Two useful functions that you should bind in SSMS

No Comments

So this is my first post in a while so I though we could look at two useful SSMS customizations that I use somewhere around 20-150 times each day. (Yes, those figures are directly correlated to the length of my workday.)

Both of them include binding functions to CTRL + F1 and CTRL + 3 (do you want them on other shortcuts feel free to chose your own). If you don’t know how to bind, just start SSMS (SQL Server Management Studio) and navigate to  -> Tools -> Options -> Keyboard -> Query Shortcuts. Read More…