Tuesday, December 2, 2014

localdb tips


SQL CLR is disabled by default, to enable:

using master

select * from sys.configurations where name = 'show advanced options'

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

select * from sys.configurations where name = 'show advanced options'

Create new localdb instance

sqllocaldb.exe create "Dev" 11.0  -s
This creates a localdb instance named Dev using the VStudio 2013 binaries and starts it.



Create  new database when getting "file already exists" errlr
-- open new query window against master db:

CREATE DATABASE CLFM ON (NAME = 'CLFM', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.mdf')
LOG ON (NAME = 'CLFM_log', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.ldf')

Efficient way to programmatically create localdb

http://www.jefclaes.be/2014/10/programmatically-force-create-new.html

Command line commands

from VStudio CMD:

get info on all db's on machine
SqlLocalDB.exe info
info on one db
SqlLocalDB.exe info UTest

SqlLocalDB.exe stop UTest
SqlLocalDB.exe start UTest

Make a copy of an existing database 

Make copies of the .ldf and .mdf files.
Then in server, right click Databases folder and select Attach. Select .mdf file. Done.

No comments:

Post a Comment