If you come across following errors in log file,
Source: MSSQLSERVER
Event ID: 17052
Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL.
Back up the TRANSACTION LOG FOR the DATABASE TO free
up SOME LOG SPACE
Make sure that TempDB is set to autogrow and do not set a maximum size for TempDB. If the current drive is too full to allow autogrow events, then arrange a bigger drive, or add files to TempDB on another device (using ALTER DATABASE as described below and allow those files to autogrow.
Move TempDB from one drive to another drive. There are major two reasons why TempDB needs to move from one drive to other drive.
1) TempDB grows big and the existing drive does not have enough space.
2) Moving TempDB to another file group which is on different physical drive helps to improve database disk read, as they can be read simultaneously.
Follow direction below exactly to move database and log from one drive (c:) to another drive (d:) and (e:).
Open Query Analyzer and connect to your server. Run this script to get the names of the files used for TempDB.
USE TempDB
GO
EXEC sp_helpfile
GO
Results will be something like:
name fileid filename filegroup size
——- —— ————————————————————– ———- ——-
tempdev 1 C:Program FilesMicrosoft SQL ServerMSSQLdatatempdb.mdf PRIMARY 16000 KB
templog 2 C:Program FilesMicrosoft SQL ServerMSSQLdatatemplog.ldf NULL 1024 KB
along with other information related to the database. The names of the files are usually tempdev and demplog by default. These names will be used in next statement. Run following code, to move mdf and ldf files.
USE master
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = tempdev, FILENAME = 'd:datatempdb.mdf')
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = templog, FILENAME = 'e:datatemplog.ldf')
GO
The definition of the TempDB is changed. However, no changes are made to TempDB till SQL Server restarts. Please stop and restart SQL Server and it will create TempDB files in new locations.
Thursday, September 10, 2009
System Database
master
Records all of the system level information for a SQL Server system.
It records all login accounts.
Records the existence of all other databases, including the location of the database files.
Records the initialization information for SQL Server;
Always have a recent backup of master available.
tempdb
tempdb holds all temporary tables and temporary stored procedures.
tempdb is a global resource; the temporary tables and stored procedures for all users connected to the system are stored there.
tempdb is re-created every time SQL Server is started so the system starts with a clean copy of the database. Because temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down, there is never anything in tempdb to be saved from one session of SQL Server to another.
By default, tempdb autogrows while SQL Server is running.
Unlike other databases, however, it is reset to its initial size each time the database engine is started.
If the size defined for tempdb is small, part of your system processing load may be taken up with autogrowing tempdb to the size needed to support your workload each time to restart SQL Server.
You can avoid this overhead by using ALTER DATABASE to increase the size of tempdb.
model
The model database is used as the template for all databases created on a system.
When a CREATE DATABASE statement is issued, the first part of the database is created by copying in the contents of the model database, then the remainder of the new database is filled with empty pages. Because tempdb is created every time SQL Server is started, the model database must always exist on a SQL Server system.
msdb
This is used by SQL Server Agent for scheduling alerts and jobs, and recording operators
Records all of the system level information for a SQL Server system.
It records all login accounts.
Records the existence of all other databases, including the location of the database files.
Records the initialization information for SQL Server;
Always have a recent backup of master available.
tempdb
tempdb holds all temporary tables and temporary stored procedures.
tempdb is a global resource; the temporary tables and stored procedures for all users connected to the system are stored there.
tempdb is re-created every time SQL Server is started so the system starts with a clean copy of the database. Because temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down, there is never anything in tempdb to be saved from one session of SQL Server to another.
By default, tempdb autogrows while SQL Server is running.
Unlike other databases, however, it is reset to its initial size each time the database engine is started.
If the size defined for tempdb is small, part of your system processing load may be taken up with autogrowing tempdb to the size needed to support your workload each time to restart SQL Server.
You can avoid this overhead by using ALTER DATABASE to increase the size of tempdb.
model
The model database is used as the template for all databases created on a system.
When a CREATE DATABASE statement is issued, the first part of the database is created by copying in the contents of the model database, then the remainder of the new database is filled with empty pages. Because tempdb is created every time SQL Server is started, the model database must always exist on a SQL Server system.
msdb
This is used by SQL Server Agent for scheduling alerts and jobs, and recording operators
Wednesday, September 9, 2009
Converting varchar to numeric for product size comparison
if the productsize is in varchar and needs to be used in the where condition for comparison of sizes it can be converted as below and used.The below case can we used in the where condition
case when productsize = '' or replace(productsize ,'"','') like '%[^0123456789.]%' then 0
else convert(numeric(18,2),replace(productsize ,'"',''))
end >= 1
case when productsize = '' or replace(productsize ,'"','') like '%[^0123456789.]%' then 0
else convert(numeric(18,2),replace(productsize ,'"',''))
end >= 1
Tuesday, September 8, 2009
SQL DB-Mail
1. open sql server managemnt studio
2. Go to Management
3. Go to database mail.
4. Right click --- select configure database mail
5. In the account name type in for example: vijay
6. Under email address enter the email id for example: xxxx@xxx.ie
7. Under reply email address enter the email id for example: xxxx@xxx.ie
8. Under sername name specifity the smtp ip address 192.169.0.x.
9. click next and finish
10. Now click on configure database mail and click on manage profile security.
11. Check the profile name and select "Yes" default profile.
2. Go to Management
3. Go to database mail.
4. Right click --- select configure database mail
5. In the account name type in for example: vijay
6. Under email address enter the email id for example: xxxx@xxx.ie
7. Under reply email address enter the email id for example: xxxx@xxx.ie
8. Under sername name specifity the smtp ip address 192.169.0.x.
9. click next and finish
10. Now click on configure database mail and click on manage profile security.
11. Check the profile name and select "Yes" default profile.
Database Backup
The following are guidelines for database backup.
Based on the data criticality and availability required the backup's can be designed.
Option -1 --- High availability
1. Have a complete hardware backup where the sql data and operating system are backed up with the appropriate raid configuration.
2. Database mirrored with witness for automatic fail over.
3. Full Database backed up every night to external media (drive or tapes)..
4. Differential transaction Database backed up every 15 min.
Option -2 --- High availability
1. System state back up including the operating system.
2. Database mirrored with witness for automatic fail over.
3. Full Database backed up every night to external media (drive or tapes).
4. Differential transaction Database backed up every 15 min.
5. Please make sure master and msdb database backed up.
Based on the data criticality and availability required the backup's can be designed.
Option -1 --- High availability
1. Have a complete hardware backup where the sql data and operating system are backed up with the appropriate raid configuration.
2. Database mirrored with witness for automatic fail over.
3. Full Database backed up every night to external media (drive or tapes)..
4. Differential transaction Database backed up every 15 min.
Option -2 --- High availability
1. System state back up including the operating system.
2. Database mirrored with witness for automatic fail over.
3. Full Database backed up every night to external media (drive or tapes).
4. Differential transaction Database backed up every 15 min.
5. Please make sure master and msdb database backed up.
SQL Tips
SQL Tips
1. Do not use the stored procedure within the DTS jobs.
2. When the server crashed or harddisk crashes, if you do not have msdb backed up the DTS Jobs are lost.
3. Please make sure your master and msdb database are backed up.
4. Also have the procedures written as stored procedures and call them in DTS.
1. Do not use the stored procedure within the DTS jobs.
2. When the server crashed or harddisk crashes, if you do not have msdb backed up the DTS Jobs are lost.
3. Please make sure your master and msdb database are backed up.
4. Also have the procedures written as stored procedures and call them in DTS.
No global profile is configured. Specify a profile name in the @profile_name parameter.
--No global profile is configured. Specify a profile name in the @profile_name parameter.
Solution
1. open sql server managemnt studio
2. Go to Management
3. Go to database mail.
4. Right click --- select configure database mail
5. Select Manage profile security
6. Under defaut profile make sure "Yes" is selected
Solution
1. open sql server managemnt studio
2. Go to Management
3. Go to database mail.
4. Right click --- select configure database mail
5. Select Manage profile security
6. Under defaut profile make sure "Yes" is selected
Subscribe to:
Posts (Atom)
