Thursday, November 03, 2005
More than one way!!!
There is more than one way to achieve a solution. Here is some of the “more than ones” from Production DBA’s point.
To find the SQL Server start date and time
Way1:
SELECT crdate from master.dbo.sysdatabases (NOLOCK) WHERE name = 'tempdb'
Way2:
SELECT login_time FROM master.dbo.sysprocesses (NOLOCK) WHERE spid = 1
To find the file type from sysfiles system table.
Way1:
SELECT filename,
CASE
WHEN (64 & status) = 64 THEN 'Log'
ELSE 'Data'
END AS FileType
FROM sysfiles (NOLOCK)
Way2:
SELECT filename,
CASE
WHEN groupid = 0 THEN 'Log'
ELSE 'Data'
END AS FileType
FROM sysfiles (NOLOCK)
------------------
To find the SQL Server start date and time
Way1:
SELECT crdate from master.dbo.sysdatabases (NOLOCK) WHERE name = 'tempdb'
Way2:
SELECT login_time FROM master.dbo.sysprocesses (NOLOCK) WHERE spid = 1
To find the file type from sysfiles system table.
Way1:
SELECT filename,
CASE
WHEN (64 & status) = 64 THEN 'Log'
ELSE 'Data'
END AS FileType
FROM sysfiles (NOLOCK)
Way2:
SELECT filename,
CASE
WHEN groupid = 0 THEN 'Log'
ELSE 'Data'
END AS FileType
FROM sysfiles (NOLOCK)
------------------