Install SQL Server from the command line

I recently had to setup a new windows dev machine with a local instance of SQL Server and it turns out you can run it completely from the command line although it’s not very obvious how. Once you download the installer it will extract everything to a folder which contains the SETUP.exe executable which you can run from the terminal and pass all the options you want instead of clicking through the UI. ...

Hide a table in sql server management studio

Apparently in sql server you can mark any table as a system table using EXEC sys.sp_MS_marksystemobject and then Management studio will hide it automatically. I ran into this because the docs say that Entity Framework 6 stores its code-first migration snapshots in a table called __MigrationHistory but I couldn’t find it because it’s hidden since it’s marked as a system table.

Use a table variable to hold a list of values

You can store a “list” of values in sql with a table variable. DECLARE @listOfIDs TABLE(id INT); INSERT INTO @listOfIDs SELECT id FROM Transactions WHERE USER='bob';