SQL Server Command Line Administration

I don’t have SQL Management Studio installed. Perhaps I should install it, it would make my life easier.

Here are the commands I used to create a new database and add myself to it as administrator. I want to own the database too. I don’t want to have to be sa (root for you mysql folk) just to be able to create tables. I want to delegate the ownership of this database instance (not the whole sql server) to a non-admin user. This is just for me, for dev on my laptop.

C:\>osql -E -S .\SQLEXPRESS -V 2 -Q "create database test2"
C:\>osql -E -S .\SQLEXPRESS -V 2 -Q "use test2;exec sp_changedbowner [theknife\jrwren]"
C:\>osql -E -S .\SQLEXPRESS -V 2 -Q "exec sp_configure ‘clr enabled’, 1"
Configuration option ‘clr enabled’ changed from 0 to 1. Run the RECONFIGURE
statement to install.
C:\>osql -E -S .\SQLEXPRESS -V 2 -Q "reconfigure"

Finding this set of commands was the must frustrating experience that I have had in a VERY long time. It made me long for Postgresql or MySQL.