You are here
Home > Software Development > Database > MS SQL Server > MS SQL Server Cheatsheet

MS SQL Server Cheatsheet

Reseeding a table identity in MS SQL Server

DBCC CHECKIDENT (tablename, RESEED, new_reseed_value)

Truncate Table

truncate tablename

Check Log size of all database

DBCC SQLPERF(LOGSPACE);

 

Connection String

Standard Security:
1. Server=ServerNameOrIpAddress;Database=DatabaseName;User Id=Username; Password=Password;

Trusted Connection:
2. Server=ServerNameOrIpAddress;Database=DatabaseName;Trusted_Connection=True;

Connection to a SQL Server instance:
1. Server=ServerNameOrIpAddress\InstanceName;Database=DatabaseName;User Id=myUsername;Password=Password;

Trusted Connection from a CE device:
1. Data Source=ServerNameOrIpAddress;Initial Catalog=DatabaseName;Integrated Security=SSPI; User ID=myDomain\myUsername;Password=Password;

Connect via an IP address:
1. Data Source=ServerNameOrIpAddress, ServerPort; Initial Catalog=DatabaseName;User ID=Username;Password=Password;

Attach a database file on connect to a local SQL Server Express instance:
1. Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;
2. Data Source=(LocalDb)\version;Initial Catalog=DatabaseName;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\DatabaseName.mdf

 

 

Leave a Reply

Top