Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scripting your database first versus building the database via SQL Server Management Studio and then generating the script

Tags:

sql

sql-server

I had a (friendly but heated) argument with my lead developer the other day because our project has TSQL Scripts that I code directly into SQL files which I then run against the database. I find that when I do this, it's easy to work out the schema in advance without fiddly pointing and clicking and then there's no opportunity to forget to generate a script to put into source control as generating the script no longer becomes a chore you have to do after the fact, but is an implicit part of the process (and also leads to cleaner scripts without the extra crap that SQL Server Management Studio inserts into the scripts it generates).

My lead developer insists that having to manually script it out is a pain in the arse and that he absolutely refuses to write his scripts by hand when there are perfectly good tools to do it without coding. I've noticed that the copying of his changes into the actual scripts tends to get delayed a bit as a result though.

What are your thoughts on the pros and/or cons of doing it one way vs the other? Am I being too rigid/old-school in my sticking to hand coding schema scripts or is he being too reliant on third party tools and losing something in the process?


2 Answers

I always script stuff myself because the wizards sometimes don't script things in a way that I like it and will also give funky names to defaults

scripting things yourself is also good in case you get laid off and you have to go for an interview where they ask you to script DDL on the whiteboard

like image 103
SQLMenace Avatar answered Jan 25 '26 11:01

SQLMenace


As I usually collaborate with a colleague during the schema design, I tend to design the schema using the GUI tools, as its easier to discuss it with a diagram of the tables in front of you. I then generate the scripts, being careful to select the exact options that I want to avoid having to make manual changes post-export.

like image 32
Matt Howells Avatar answered Jan 25 '26 11:01

Matt Howells