DBA In A Box we
save you money SQL server database monitoring, troubleshooting, and analyzing software with tools designed to scan, alert, and investigate SQL server failures, performance, SOX compliance, replication failures and much more. |
Home About Us Screen Shots Contact Us Downloads SQL Scripts Auto Manage Indexing Auto Reindex Database Mirroring SQL Performance Check Security |
Create a SQL server Install folder on a shared drive: Use this when you need to deploy a CD to multiple users. a good example would be developers that need a sql server developer copy for their local desktop.
These
two folders must be under the same level of a folder or the root folder
of a
drive. The names of these folders must be exactly Servers and Tools.
The
Servers folder contains all the files that are required to install
major SQL
Server 2005 components, such as database engine. The Tools folder
contains
tools components and Books Online for SQL Server 2005. To
copy the files from the SQL Server 2005 installation CDs to a location
and then
install SQL Server 2005 from that location, follow these steps: Note
In this example, the D:\SQLServer2005 folder is the location to which
you want
to copy the files from the SQL Server 2005 installation CDs. In
the D:\SQLServer2005 folder, create the following two subfolders: Servers Copy
all the files from the SQL Server 2005 installation CD that is named
Servers to
the D:\SQLServer2005\Servers folder.
What Users are accessing the server sp_who / sp_who2 Statistics exec sp_updatestats -- update all tables in a database with new statistics update statistics tblcustomers -- update statistics for the single table tblcustomers. update statistics tblcustomers IX_tblcustomers_custid -- update statistics for a single index dbcc showcontig (tblcustomers) -- show the contigous space on the tblcustomers table. dbcc showcontig ('tblcustomers') with tableresults, all_indexes --show statistics for all indexs in the table dbcc updateusage ('MyDatabase','tblcustomers') --:Reports and corrects pages and row count inaccuracies in the catalog views.
How to replicate a single article Add the article to the
publication. Kill
non
replication transactions ,@xact_segno = NULL ,@numtrans = 0 ,@time = 0 ,@reset = 1 Hard
remove
replication from a database. sp_dboption TAZ_MRKT,'publication',false Un-commited transactions dbcc opentran(xstore) with tableresults --Shows open Transactions that may be preventing logs from clearing. ACTIVE
DIRECTORY sp_addlinkedserver 'ADSI','Active Directory Services 2.5','ADSDSOObject','adsdatasource' go
Create a Plan Guide: Use this to force a query plan on a dynamic query that is heavily re-used. Dynamic queries can use up the plan cache fast this is a quick solution in some cases. DECLARE @stmt nvarchar(max) DECLARE @params nvarchar(max) EXEC sp_get_query_template N'select * from Sales.SalesOrderHeader where ShipDate between ''2001-07-08'' and ''2001-07-13'' and status = 5', @stmt OUTPUT, @params OUTPUT EXEC sp_create_plan_guide N'PlanGuideFor_SalesByDate', @stmt, N'TEMPLATE', NULL, @params, N'OPTION(PARAMETERIZATION FORCED)' To view your Plan guide select * from sys.plan_guides where name = N'PlanGuideFor_SalesByDate' Restore Help Restores sound simple but there are many options and you need to be careful. Below are some templates I use to do specific task. Get information about the backup no update takes place RESTORE filelistonly FROM DISK = '\\bkupserver\model\model_db_200710160200.bak' RESTORE Headeronly FROM DISK = '\\bkupserver\model\model_db_200710160200.bak' RESTORE Labelonly FROM DISK = '\\bkupserver\model\model_db_200710160200.bak' Simple Restore Default options RESTORE DATABASE Northwind FROM DISK = 'C:\Backups\Northwind_Full_20060307.BAK' Simple differential database restore (restores one full backup and one differential backup): RESTORE DATABASE Northwind FROM DISK = 'C:\Backups\Northwind_Full_20060307.BAK' WITH NORECOVERY --Note the norecovery do not rollback transactions. RESTORE DATABASE Northwind FROM DISK = 'C:\Backups\Northwind_Diff_20060307.BAK' Note: A transaction log restore must follow a full database restore, a differential database restore or another transaction log restore using the NORECOVERY option after each previous restore command. Simple transaction log restore (restores one full backup and one transaction log backup): RESTORE DATABASE Northwind FROM DISK = 'C:\Backups\Northwind_Full_20060307.BAK' WITH NORECOVERY RESTORE LOG Northwind FROM DISK = 'C:\Backups\Northwind_Log_20060307.BAK' Restore to a different server and map new file locations. RESTORE DATABASE Northwind FROM DISK = 'C:\TEMP\Northwind.bak' with recovery, MOVE 'Northwind_Data1' TO 'E:\MSSQL\Data\Test_Northwind_Data1.mdf', MOVE 'Northwind_Data2' TO 'E:\MSSQL\Data\Test_Northwind_Data2.ndf', MOVE 'Northwind_Log' TO 'E:\MSSQL\Logs\Test_Northwind_Log.LDF'; Restore to a point in time RESTORE DATABASE Northwind FROM DISK = 'C:\Backups\Northwind_Full_20120307.BAK' WITH NORECOVERY RESTORE LOG Northwind FROM DISK = 'C:\Backups\Northwind_Log_20120307.BAK' WITH STOPAT = N'1/06/2012 6:23:36 PM' Restore with different database name: use the replace option if the backup came from another database. RESTORE DATABASE Northwind FROM DISK = 'C:\Backup\Southwind_Full_20060307.BAK' WITH REPLACE
|