Using Tsql, how can I find out when MS SQL server was installed?
The NT AUTHORITY\SYSTEM login is created when you install SQL Server, so:
SELECT createdate
FROM sys.syslogins
WHERE name = 'NT AUTHORITY\SYSTEM'
This will return an incorrect result however if you've ever restored the Master database.
It looks like the first 100 principal_id values are reserved in sys.server_principals (SQL Server 2005+). Based on what I see in one of my sys.server_principals (SQL Server 2005, SP3), I'd try this:
SELECT MIN(create_date) FROM sys.server_principals WHERE principal_id > 100
Related
I need query to get server_name, instance_name, machine_name, database_name, recovery_model, isclustered in SQL Server 2012 and above.
Thanks
You should use sys.databases view and add few SERVERPROPERTY metadata informations.
Something like this:
SELECT SERVERPROPERTY('MachineName') AS MachineName,
SERVERPROPERTY('ServerName') AS ServerName,
name AS DatabaseName,
recovery_model_desc AS RecoveryModel
FROM sys.databases
Getting information about Cluster is described here:
TSQL - how to tell if SQL is clustered?
How to find SQLServer Virtual Cluster name
Try this ...
SELECT
SERVERPROPERTY('MachineName') AS ComputerName,
SERVERPROPERTY('ServerName') AS InstanceName,
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('IsClustered') AS IsClustered,
SERVERPROPERTY('ProductLevel') AS ProductLevel;
GO
More details on properties : https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql
THIS TOPIC APPLIES TO:
SQL Server (starting with 2008)
Azure SQL Database
Azure SQL Data
Warehouse Parallel Data Warehouse
Returns property information about the server instance.
I do not have access to the machine but I want to find out when this sql server was installed?
I have Server View state access which means I can access dmvs but I cannot connect to the machine, I cannot find any DMV with this information.
I don't think this information is held in any of the DMVs but a place I usually look for is the sys.server_principals. Look for the SYSTEM or NETWORK SERVICE logins, this will indicate you when this SQL Server was installed.
Select Create_Date
FROM sys.server_principals
WHERE name = N'NT AUTHORITY\SYSTEM'
OR name = N'NT AUTHORITY\NETWORK SERVICE'
use sys.server_principals
SELECT create_date,*
FROM sys.server_principals
WHERE sid = 0x010100000000000512000000 -- sid of NT AUTHORITY\SYSTEM
Referred from below article by Pinal Dave
SQL SERVER – Retrieve SQL Server Installation Date Time
This article How to find out the SQL Server installation date? has much more options
-- work with only English language installations
SELECT createdate AS 'SQL Server Installation Date'
FROM sys.syslogins
WHERE NAME = 'NT AUTHORITY\SYSTEM'
--neutral language
SELECT createdate AS 'SQL Server Installation Date'
FROM sys.syslogins
WHERE sid = 0x010100000000000512000000
--Using sys.server_principals
SELECT create_date as 'SQL Server Installation Date'
FROM sys.server_principals
WHERE name='NT AUTHORITY\SYSTEM'
I know this has been asked before but I couldn't find a solution... I had to change a server name for a SQL Server 2012 machine after moving it to a new domain. I was able to log into single user mode and enable SQL Server authentication and add a SQL Server user. I'm able to login that way, but the software that uses the DBs on the server require Windows Authentication.
I've tried running
sp_addserver 'Servername', local;
The server responds with The server already exists, but I still cannot login with Windows Authentication... please help.
In order to change server name(on instance), after you changed windows server name, you should execute:
sp_dropserver <old name>;
go
sp_addserver <new name>, local;
go
Where are SQL Server user name and password stored?
In the DB called "master", you can view them with:
SELECT * FROM master.sys.syslogins
However passwords are encrypted.
As per Richard's comment: please note that syslogins is no longer a physical table (in SQL server 2005 and 2008) but only a view provided for backwards compatibility.
I'm currently using SQL 2000 (it's a vendor server - don't ask...), and I'm wondering if there's a way to detect the connection protocol of connected clients. For SQL 2005+, I use:
select net_transport from sys.dm_exec_connections
where session_id = ##spid
But SQL2000 lacks this dynamic view. Anybody know the equivalent function on SQL2000?
SELECT net_library FROM sysprocesses WHERE spid = ##SPID
You can also sys.sysprocesses in SQL Server 2005/2008. It may be deprecated but there is no equivalent in after SQL 2000 for functionality, says MS Connect 144515