Posts

Showing posts with the label sql server

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 N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\Setup', N'SQLPath', @dir output, 'no_output' select @dir AS InstallationDirectory

C# - Finding SQL Server Data Sources and Databases

For those exploring how to finding data sources, database names, etc - using C#, you can do the following: // Retrieve the enumerator instance, and then retrieve the data sources. SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; DataTable dtDatabaseSources = instance.GetDataSources(); // Populate the data sources into DropDownList. foreach (DataRow row in dtDatabaseSources.Rows) if (!string.IsNullOrWhiteSpace(row["InstanceName"].ToString())) cboDatasources.Items.Add(row["ServerName"].ToString() + "\\" + row["InstanceName"].ToString()); The code above however, did not show the local instances of SQL Server 2008 R2. So, to acquire your local instances as well, you will need to use the SMO ManagedComputer object, which provides an interface to the WMI Provider for Configuration Management. You will need to add the following references to the project (using VS2010), in C:\Program Files...

SQL Server Business Intelligence - Lost Report Data Window

In an unlikely circumstance that you happen to lose the Report Data Window , in SQL Server Business Intelligence, you won't simply find it in your VIEW menu options. There is a simple keyboard shortcut to re-create this window, which is CTRL+ALT+D .