|
|
-
|
|
Finding database creation time is simple if database has not been detached from server. You can find database creation time using below methods.
Using sp_helpdb:
You can find the creation time of database using sp_hepldb system procedure.
EXEC sp_helpdb ...
|
|
-
|
|
SQL Server error logs can fill up quickly, and when you are troubleshooting something you may need to go through huge log. However you can cycle the error log to manage the amount of log you need to go through. When you cycle error log the current log file...
|
|
-
|
|
Earlier on my blog I posted about how you can attach a database using T-SQL when no log file is available. You can catch that here. In this post we will see how it can be attached using GUI.
To attach a database with no .ldf file, follow below steps:
1. Op...
|
|
-
|
|
In SQL Server you can enable a Trace Flag at session (effective for current session only) level and global level. If you are not sure which Trace Flags have been enabled you can use DBCC TRACESTATUS() command to get a list of enabled Trace Flags.
DBCC TRAC...
|
|
-
|
|
You can use WITH CHECKSUM option to perform checksum when backup is created. When used this verifies each page for checksum and torn page.
You can use it in a BACKUP command as below:
BACKUP DATABASE [SqlAndMe]
TO DISK = N'C:\SqlAndMe.bak'
WITH C...
|
|
-
|
|
Each login in SQL Server has a default database associated with it. When you login to SQL Server context is set to default database for login. This is set when login is created and it can be changed by using ALTER LOGIN command.
If for some reason the def...
|
|
-
|
|
You can avoid executing a function when NULL values are passed as parameters. To achieve this you need to create function with RETURNS NULL ON NULL INPUT, this option introduced in SQL Server 2005.
You can use this while creating a function as below:
USE [...
|
|
-
|
|
To check SQL Server Agent Job History you can use the Log File Viewer from SQL Server Management Studio.
To Open Log File Viewer,
1. Expand Server Node > 2. Expand SQL Server Agent > 3. Expand Jobs > 4. Right click on the Job and 5. Select "View Histo...
|
|
-
|
|
SQL Server stores all mails and attachments in msdb database. To avoid unnecessary growth of msdb database you should remove these mail history unless it is required for auditing or other purposes.
To check all mails processed by Database Mail, you can use...
|
|
-
|
|
Generally it is considered good practice using two-part names for objects. It make the code more readable and avoids confusion if objects with similar names exists in different schemas. Some features requires that two-part naming must be used such as creat...
|
|