SQL Join Diagram and Query Create TableA and TableB and Populate Data CREATE TABLE TableA ( ID INT IDENTITY(1, 1) , [Key] NVARCHAR(255) , Value NVARCHAR(4000) , CreatedDateTime DATETIME2 DEFAULT GETUTCDATE() , CreatedBy NVARCHAR(50) DEFAULT CURRENT_USER , Status TINYINT DEFAULT 1 ); CREATE TABLE TableB …
Run SQL Scripts using PowerShell
Run SQL Scripts using PowerShell We all have the need to run SQL Scripts against Multiple Servers on Daily Basis. Sometimes, Its cumbersome to manually run the scripts against the server using Management Studio. This powershell Script comes handy to run multiple scripts against specified …
Common SQL Tasks I Do and Scripts
Common SQL Tasks I Do and Scripts Restore a database from Backup : RESTORE FILELISTONLY FROM DISK = ‘\\FileShare\Database\Database.bak’ RESTORE DATABASE SmarterTrack FROM DISK = ‘\\FileShare\Database\Database.bak’ WITH REPLACE , MOVE ‘SmarterTrackModel’ TO ‘G:\SQLServer\MSSQL10_50.DEV2008R2\MSSQL\DATA\SmarterTrack.mdf’ , MOVE ‘SmarterTrackModel_log’ TO ‘G:\SQLServer\MSSQL10_50.DEV2008R2\MSSQL\DATA\SmarterTrack_log.ldf’ EXEC sp_helpdb ‘SmarterTrack’ Run Multiple SQL Files …
Common SQL Errors and Solutions
Error : Msg 7411, Level 16, State 1, Line 1 Server ‘DEVSQLDEV2008’ is not configured for RPC. Solution : exec sp_serveroption @server=’DEVSQLDEV2008′, @optname=’rpc’, @optvalue=’true’ exec sp_serveroption @server=’DEVSQLDEV2008′, @optname=’rpc out’, @optvalue=’true’ Error : 2014-09-11 16:14:23.410 Logon SSPI handshake failed with error code 0x8009030c while establishing a …
Measure T-SQL / Stored Procedure Performance
Measure T-SQL / Stored Procedure Performance If you are using SQL Server or dealt with SQL Server in any fashion, you might have heard this million times, How do you measure the TSQL ( Adhoc ) or Stored Procedure Performance. I have been using Microsoft SQL …
SQL Server – Orphaned Users
SQL Server – Orphaned Users A database user for which the corresponding SQL Server login is undefined or is incorrectly defined on a server instance cannot log in to the instance. Such a user is said to be an orphaned user of the database on …