code_junkie

SQL Server: How to SELECT the installation path

Nov 14th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. c:Program FilesMicrosoft SQL ServerMSSQL.7MSSQL
  2.  
  3. m:CustomInstanceMSSQL
  4.  
  5. select filename from sysaltfiles
  6. where name = db_name()
  7.  
  8. Server: Msg 208, Level 16, State 1, Line 1
  9. Invalid object name 'sysaltfiles'.
  10.  
  11. select filename from master.dbo.sysaltfiles
  12. where name = db_name()
  13.  
  14. filename
  15. ----------------
  16.  
  17. (0 row(s) affected)
  18.  
  19. declare @rc int, @dir nvarchar(4000)
  20.  
  21. exec @rc = master.dbo.xp_instance_regread
  22. N'HKEY_LOCAL_MACHINE',
  23. N'SoftwareMicrosoftMSSQLServerSetup',
  24. N'SQLPath',
  25. @dir output, 'no_output'
  26. select @dir AS InstallationDirectory
  27.  
  28. declare @rc int, @dir nvarchar(4000)
  29.  
  30. exec @rc = master.dbo.xp_instance_regread
  31. N'HKEY_LOCAL_MACHINE',
  32. N'SoftwareMicrosoftMSSQLServerMSSQLServer',
  33. N'BackupDirectory',
  34. @dir output, 'no_output'
  35. select @dir AS BackupDirectory
  36.  
  37. Declare @Path as varchar(100);
  38. Set @Path = NULL
  39.  
  40. Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWAREMicrosoftMicrosoft SQL Server70ToolsClientSetup', 'SQLPath', @Path OUTPUT
  41. Select @Path as [Sql Server 7.0 path]
  42.  
  43. Set @Path = NULL
  44. Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWAREMicrosoftMicrosoft SQL Server80ToolsClientSetup', 'SQLPath', @Path OUTPUT
  45. Select @Path as [Sql Server 2000 path]
  46.  
  47. Set @Path = NULL
  48. Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWAREMicrosoftMicrosoft SQL Server90ToolsClientSetup', 'SQLPath', @Path OUTPUT
  49. Select @Path as [Sql Server 2005 path]
  50.  
  51. Set @Path = NULL
  52. Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWAREMicrosoftMicrosoft SQL Server100ToolsClientSetup', 'SQLPath', @Path OUTPUT
  53. Select @Path as [Sql Server KATMAI path]
  54.  
  55. select filename from sysaltfiles
  56. where name = db_name()
Add Comment
Please, Sign In to add comment