|
|
-
|
|
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 [...
|
|
-
|
|
You can easily import data from an Excel file to SQL Server using SQL Server Import and Export Wizard. However, when the data is simple and limited I avoid using it (too lazy to click through 6 screens… ) instead I generate INSERT statements using CONCAT...
|
|
-
|
|
When it comes to exporting data there are different options available in SQL Server, such as SQL Server Integration Services, Generating Insert Scripts, BCP, Import and Export Wizard and SQLCMD.
When it comes to exporting data as CSV file, BCP and SQLCMD a...
|
|
-
|
|
This is a follow up post from a comment on my blog.
Earlier I posted about using xp_instance_regread to get default data location for current instance. It translates a given registry path to instance specific registry path. This can return the value for a ...
|
|