Create SQL Login Account Script

sp_change_users_login Maps an existing database user to a SQL Server login.  Syntax Arguments [ @Action= ] ‘action‘Describes the action to be performed by the procedure. action is varchar(10). action can have one of the following values. Value Description Auto_Fix Links a user entry in the sys.database_principals system catalog view in the current database to a SQL Server login of the... » read more

Create Database Script

Example 1 Example 2 Make sure the following folders are created already. C:\MSSQL\MyDatabase01\Data C:\MSSQL\MyDatabase01\Log Result: C:\MSSQL\MyDatabase01\Data\MyDatabase01.mdf C:\MSSQL\MyDatabase01\Data\fgData_01.ndf C:\MSSQL\MyDatabase01\Data\fgIdx_01.ndf C:\MSSQL\MyDatabase01\Log\MyDatabase01Log_01.ldf

int, bigint, smallint, and tinyint in SQL Server

Data type Range Storage bigint -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) 8 Bytes int -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) 4 Bytes smallint -2^15 (-32,768) to 2^15-1 (32,767) 2 Bytes tinyint 0 to 255 1 Byte Sources: https://docs.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql?view=sql-server-2017

Always On Availability Group Configuration

By default both read-write and read-intent access are allowed to the primary replica and no connections are allowed to secondary replicas of an Always On availability group.  Permissions Task Permissions To configure replicas when creating an availability group Requires membership in the sysadmin fixed server role and either CREATE AVAILABILITY GROUP server permission, ALTER ANY AVAILABILITY GROUP... » read more

@@ServerName

Get the actual server name of the current SQL Server. Useful when you are using listeners to connect into SQL Server and need to know the exact server name you are connected into.