Use SQL to drop a column, if it exists in a table

05 Apr 2016 Databases, SQL, Stored Procedures No Comments

I recently needed to write a script for a customer to run against their database, to delete a column from a table. I wanted to make sure it would only run if that column existed, especially as the column had originally been created by a script that failed to complete

Continue reading →

Adding a relationship constraint to an existing or new column in MS SQL

24 Mar 2016 Databases, SQL, Stored Procedures No Comments

I recently needed to write some SQL to add a relationship constraint to an existing column in MS SQL. After a bit of research this is the answer I found. I have also included the SQL for adding the same constraint when creating a new table also.   Resource: Continue reading →