SQL - Finding SQL Server Installation Path

If trying to automate creating databases you may need to get the installation path of the SQL Server instance you are connected to, to do this use the following query.
declare @rc int, @dir nvarchar(400) 
exec @rc = master.dbo.xp_instance_regread
      @dir output, 'no_output'
select @dir AS InstallationDirectory
Post a Comment

Popular posts from this blog

C# - ListView Item Spacing (Padding)

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)

C# - Performance Counters