0% found this document useful (0 votes)
23 views4 pages

MS SQLServer DBA Tutorial 01 1655199992

Uploaded by

venkataprudhivi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

MS SQLServer DBA Tutorial 01 1655199992

Uploaded by

venkataprudhivi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MS SQL Server DBA Troubleshooting Tips

Sl Problem Environment Fix / Solution.


No Reported / / Comments
General
point

1 sa could not Any Change SQL server instance properties


get and allow both the types of
connection authentications.

2 How to check Any Select SERVERPROPERTY('ProductLevel')


database
version

3 Query to Any SELECT SERVERPROPERTY('productversion')


check which AS SQLServerVersion,
version/
service pack SERVERPROPERTY ('productlevel') AS
ServicePackLevel, SERVERPROPERTY

('edition') AS SQLServerEdition

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

SELECT 'SQL Server '

+ CAST(SERVERPROPERTY('productversion')
AS VARCHAR) + ' - '

+ CAST(SERVERPROPERTY('productlevel')
AS VARCHAR) + ' ('

+ CAST(SERVERPROPERTY('edition') AS
VARCHAR) + ')'

4 Query to get Any


the SQL
instance SELECT @@SERVERNAME AS 'Server Name'
name

5 Command to Any SELECT * FROM ::fn_trace_getinfo(NULL)


get running
traces
MS SQL Server DBA Troubleshooting Tips

6 Command to Any 1. EXEC sp_trace_setstatus


stop trace
by getting @traceid = <traceid> , @status
the trace id = 0
from the
above query.

7 Close the Any 1. EXEC sp_trace_setstatus @traceid


trace and
delete the = <traceid> , @status = 2
trace
information

8 Query to Any SELECT *


check if any FROM fn_trace_getinfo(default);
traces are GO
running.

9 To get Any By using the system function,


fragmentatio
n related sys.dm_db_index_physical_stats, you can
information detect fragmentation in a specific
on an SQL index,all indexes on a table or indexed
instance. view, all indexes in a database, or all
indexes in all databases. For
partitioned indexes,
sys.dm_db_index_physical_stats also
provides fragmentation information for
each partition

10 To remove Any NOT ADVISED WITHOUT CONSULTATION AND


the auto APPROVAL
shrink
property of
the database Ensure that AUTO_SHRINK is turned off
and to
by default. If free space must be
manually
generated,do that by using the DBCC
shrink file SHRINKFILE or DBCC SHRINKDATABASE
or the commands.
database and
then as a In addition, always rebuild or
best reorganize the indexes after a shrink
practice to operation in order to fix any
defragment fragmentation that might have occurred
the indexes. in the data files.
MS SQL Server DBA Troubleshooting Tips

11 To change Any On a production server, the Recovery


the recovery Model should be set to Full or Bulk-
model to Logged except in special circumstances.
Full. Because the Simple Recovery Model does
not make use of transaction log
Transactions backups, all activity since the last
logs are not database backup will be lost in the
backed up in event that the database needs to be
the simple restored.
model.Data
can be The Recovery databasepropertyex
recovered property exposes the current setting of
only upto the
the complete
restore but Recovery Model for the database in
cannot be question. To determine the Recovery
rolled Model for a database, query the
forward from ?Recovery? databasepropertyex for the
there.Hence database by viewing the Options panel
data loss. of the Properties for the database
using Management Studio, or

by running the following command:

Select databasepropertyex(?
database_name ?, ?Recovery?);

The possible output values for this


are:

FULL = Full recovery model

BULK_LOGGED = Bulk logged model

SIMPLE = Simple recovery model

Recommended

Resolution

Review the database recovery model for


the
MS SQL Server DBA Troubleshooting Tips

12 Shrink the Any BACKUP LOG <DBName> WITH No_log


log file to
free up
unused DBCC SHRINKFILE
pages.
(DBName_logfilename,sizeinMB);

GO

13 DBCC Any CREATE table dbccOpenTran


commands to
(
Check for
any open <dbname> sysname
transaction , OpenTran varchar(30)
and also
store the , ntime datetime DEFAULT getdate()
results in a
table. )

insert into dbccopentran (<dbname>,


opentran)

exec ('dbcc opentran with tablereults')

14 Database Any DBCC CHECKDB (<DBNAME>) WITH


Consistency ALL_ERRORMSGS;
Check (DBCC)
GO

15 Query to Any use [DBNAME]


list all the
user tables. GO

select * from sysobjects where


xtype='U' order by name;

GO

You might also like