Sei sulla pagina 1di 4

http://www.sqlservercentral.

com/
http://blog.sqlauthority.com/
mssqltips.com
http://www.sqlserver-dba.com
Experience with database tuning using SQL Sentry , SCOM 2012

ALTER DATABASE DBI SET OFFLINE WITH ROLLBACK_IMMEDIATE


move data and log file to different location
run following T-sql

ALTER DATABASE DB1 MODIFY FILE(NAME=db1_DATA,FILENAME = D:\SQL SERVER


\DB1_DATA.MDF);
ALTER DATABASE DB1 MODIFY FILE(NAME=db1_LOG,FILENAME = D:\SQL SERVER \DB1_LOG.LDF);
ALTER DATABASE DB1 SET ONLINE

0) ALTER DATABASE TESTDB2 SET EMERGENCY


1) ALTER DATABASE TestDB2 REBUILD LOG ON
(NAME=TestDB2_Log,FILENAME='D:\SQLLog\TestDB2_Log.ldf')
2) dbcc checkdb (testdb2)
3) ALTER DATABASE TESTDB2 ONLINE
4) ALTER DATABASE testdb2 SET MULTI_USER

select serverproperty('EDITION') As Edition


select serverproperty('PRODUCTLEVEL') As [Product Level]
select serverproperty('PRODUCTVERSION') As Version

connecting to sql bt sqlcmd

sqlcmd -S .\instance name (case sensetave)

RESTORE DATABASE master FROM DISK = 'C:\MINIDR\masterbackupfile.bak' WITH


RECOVERY, REPLACE;

for tranaction log viewing...........

DBCC LOG(<databasename >, <type of output>)

<type of output>

0: Return only the minimum of information for each operation -- the operation, its
context and the transaction ID. (Default)
1: As 0, but also retrieve any flags and the log record length.
2: As 1, but also retrieve the object name, index name, page ID and slot ID.
3: Full informational dump of each operation.
4: As 3 but includes a hex dump of the current transaction log row.

select * from fn_dblog (null,null) ..


EXAMPLE:
SELECT * FROM::fn_dblog(NULL, NULL)
WHERE operation = 'LOP_DELETE_SPLIT'

For index....
use database
exec sp_help tabalename

I'l like to get the DBs status on a Server. Means, I need to know what are the DBs
are being used,
what are not being & if any are in use, I need to know when it was used last time
and how frequently
its been used in the past several month.

Answered

select s.database_id as database_id


,db.name as database_name
,max(s.last_user_scan) as last_user_scan
from sys.dm_db_index_usage_stats as s
join sys.databases as db
on db.database_id = s.database_id
group by s.database_id,db.name
order by db.name asc

You can get block processes by executing SP_LOCK or SP_LOCKDETAIL.


you can't roll back anything rather killing the process from Management Module.

select *
from fn_trace_gettable('c:\MyTraceFile.trc', default)

--------------------------------------------------------------------------------

Difference between Index Rebuild and Index Reorganize Explained View(s): 3754
What is difference between rebuild and reorganize the indexes in SQL Server 2005?
When should i go for rebuild the index and when should i go for reorganize the
index?
Answer 1)
--------------------------------------------------------------------------------

Index Rebuild: This process drops the existing Index and Recreates the index.
USE AdventureWorks;
GO
ALTER INDEX ALL ON Production.Product REBUILD
GO

Index Reorganize: This process physically reorganizes the leaf nodes of the index.
USE AdventureWorks;
GO
ALTER INDEX ALL ON Production.Product REORGANIZE
GO

You need to check the fragmentation (using DBCC showcontig) for indices to decide
what to go for rebuild or reorganize.

Recommendation: Index should be rebuild when index fragmentation is great than 40%.
Index should be reorganized when index fragmentation is between 10% to 40%. Index
rebuilding process uses more CPU and it locks the database resources.

Bhoomika_bhandari@dell.com
careers@bartronicsindia.com
careers@unissl.com.
itjobs@emerson.com
india@winshuttle.com

Looking for 5-8 years L3 candidates


Good knowledge on SQL Server 2005 & 2008 database architect
Knowledge of SQL Server Clustering 2005 & 2008
SQL server log shipping and mirroring knowledge
SQL Server 2005 & 2008 Install
Knowledge of writing T-SQL queries
Data Refresh Good Knowledge on replication Monitoring & Administration
Database instance availability Session monitoring
Query/Transaction monitoring
Transaction log/ Trace file monitoring
Lock/Deadlock monitoring
Memory and Cache monitoring
Job Monitoring and Purging Job History
Object monitoring and maintenance
User access rights, password resets
Database Creation
System Recovery Execution
Application Specific Backup/Recovery Execution
Service Pack Up gradation
Performance Tuning
Physical Database Design
Capacity planning / Trend analysis and Recommendation

1. Check the email alerts to see if anything needs to be addressed. We use MOM to
monitor our environments, so MOM notifies us of issues.
2. Work on production tickets
3. Work on dev/test/perf/... tickets
4. Work on project tasks
5. Proactive administration (performance mostly)
6. Automating things when I can
...

USE [WSS_ApplicationUsage]
GO
ALTER DATABASE [WSS_ApplicationUsage] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(N'WSS_ApplicationUsage_log', 1)
ALTER DATABASE [WSS_ApplicationUsage] SET RECOVERY FULL WITH NO_WAIT

GO

If the database is online and begin to restore the database after backup BACKUP
LOG [database_name] TO [backup_device] WITH NORECOVERY
-- If the database is offline, and log file may be damaged BACKUP LOG
[database_name] TO [backup_device] WITH CONTINUE_AFTER_ERROR

Potrebbero piacerti anche