How to access Server Properties in SQL Operations Studio? - tsql

In Microsoft SQL Server Management Studio, there is the option to right click on a server to get to: Server Properties - Security
What is the equivalent of that in the new SQL Operations Studio ?
Thanks.

This does not fully answer the question, but here goes.
The Server properties -> Security is generated via querying the Windows Registry. There is no simple way to query it out of the system.
You can use
exec master.dbo.xp_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\Setup',
N'SQLPath',
#dir output
select #dir
exec master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\Setup',
N'SQLPath',
#dir output
select #dir
The problem is, you have to know where in N'HKEY_LOCAL_MACHINE', to find what you are looking for.
This answer was based on: Differences between xp_instance_RegRead and xp_RegRead

Related

Import Excel 2010 into SQL Server

I use Excel to collect & configure data, then import it into SQL Server 2012 for storage.
So far I've been using the SQL Server Import & Export Wizard, but it is a pain to manually set it up constantly. Since I'm using Express, of course it won't allow me to save, or even view, the actual commands to transfer the data.
I tried to set up a linked server, per How to use Excel with SQL Server linked servers and distributed queries, but get the following error:
The linked server has been created but failed a connection test. Do you want to keep the linked server?
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "FLTST".
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "FLTST" returned message "Unspecified error". (Microsoft SQL Server, Error: 7303)
I thought perhaps the Excel version number was the problem, since the web page is from 2005, so I tried with:
Excel 8.0 (Excel 2002) as shown on the page
Excel 12.0 (Excel 2007) which is what the wizard seems to use
Excel 14.0 (Excel 2010) what I actually have
All of those gave me identical results.
Next I tried the distributed query as shown at Import excel file to SQL Server Express, (again with different variations of the provider string)
USE ExTest
SELECT * INTO TstTbl FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 14.0;Database=c:\ExTest.xlsm', [Contacts])
go
Which gives me the following error:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 3
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
Instead of going to SQL Server & pulling the data in, should I stay in Excel & push it over?
What am I doing wrong?
PS: Please don't tell me to convert it to a csv file! I'm trying to do fewer steps, not more!
Having similar issues as you have in your question I have done some research on this. My issue is not yet fully resolved but I think I might get you one step further. Although the question is old there is perhaps someone else who needs the help.
By running:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=YES;Database=P:\Path\File.xlsx','SELECT * FROM [Sheet1$]');
GO
I get the following error message:
Msg 15281, Level 16, State 1, Line 19
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.
To resolve that I run the following:
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
But I get a new error mesasge:
Msg 7302, Level 16, State 1, Line 19
Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
To rectify that I run:
EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO
But I get this error in stead:
Msg 7438, Level 16, State 1, Line 19
The 32-bit OLE DB provider "Microsoft.ACE.OLEDB.12.0" cannot be loaded in-process on a 64-bit SQL Server.
In my case I have asked the IT department to install a 64 bit version of excel on the server and I hope that should be the end of the technical problems when importing from excel.
To clean up afterwards I disable the settings I just enabled:
EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 0
GO
EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 0
GO
sp_configure 'ad hoc distributed queries', 0
RECONFIGURE
GO
sp_configure 'show advanced options', 0
RECONFIGURE
GO
Create an SSIS package with Excel data source connection manager, destination is your SQL express, OLE DB destination
When you create Excel connection manager, you can just use one existing excel file
Define one user variable, like user::sourceFile, which is used to input excel file full path
After Excel connection manager is created, right click-> preperties-> find the "Expression", just give your [User::sourceFile] to the Expression
Just create one simple data flow from your source to destination
Save and debug your SSIS package, make sure all credential works and data can flow into destination table. Note: don't save sensitvie data in your package with ecrypted by machine key
Each time when you need to load a new file, use DTEXEC to execute package and override the parameter
good luck

SQL Studio Management - How to run queries across multiple servers

My 2 server both use SQL Server 2008 R2
I have my local SQL server and also an Amazon machine running an instance of SQL-Server there.
I'm able to connect from my local machine to that Amazon SQL using the standard 10.10.10.10, 1433 connection from my local Management Studio.
What i need to do now is to run a query that says ..tells me what records I have locally that are not on the Amazon server right now.
Something like:
SELECT *
FROM [LOCAL].dbo.Table1
WHERE Field1 NOT IN
(SELECT Field1 FROM [AMAZON].Database1.dbo.Table1)
================================
Question:
I don't know how to write the "AMAZON" location on the Query window itself, since it's running on a different server.
Any help is truly appreciated !!!
You have to configure AMAZON Server as LINKED Server on your local machine. If you name it "AMAZON" - you query will work exactly as you wrote.
In SSMS, \Server Objects\Linked Servers. Right click, 'new linked server'. Name your server, and choose 'SQL server' radio button. Because I was authorized user on both machines with windows credentials, I selected 'Be made using the login's current security context' radio button under the security tab, and did not even have to fool with the local/remote user mappings.
In order to be able to run queries across multiples servers, a link (linked Server) must be established between the 2 Servers. To create a linked server,
Navigate to the Linked Server Sub-folder under the Server Object folders
Right Click on the Linked Server Folder
Click on New Linked Server
Supply the Connection Strings for the Server
Name your Linked Server.
You can now use the full object qualification (LinkedServer.Database.tableOwner.Table) to access the objects.
Good Luck !
You should open your registered server window and create a group for your servers. then you right click the group name and select new query (Or select several servers in that group). if you execute the query it will rung against the servers selected.

Connect/read FoxPro/.dbf file, from TSQL

This seems like it should be easy enough, but I'm having trouble in what feels like the final stretch..
I want to connect to a Fox Pro .dbf file
1.) I've applied the following changes on my local SQL instance. All the code was found via various google results (I'm not an expert on this at all)
USE [master]
GO
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
GO
EXEC master.dbo.sp_MSset_oledb_prop N'VFPOLEDB', N'AllowInProcess', 1
RECONFIGURE
GO
EXEC master.dbo.sp_MSset_oledb_prop N'VFPOLEDB' , N'DynamicParameters' , 1
RECONFIGURE
GO
2.) When I run the following (which by the sound of it, is where the magic should happen)
select * from
openrowset('VFPOLEDB','\\path_segment\path_segment\clock.dbf';'';'','SELECT * FROM clock')
I get an error..
OLE DB provider 'VFPOLEDB' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.
... and that's basically where my google skills end, any ideas on what I can do to get the above working?
Not sure if it can help, but I posted an answer for this thread for someone trying to deal with converting VFP tables to SQL. The starting point I offered the person appeared to have him on the right track.
It deals with linked server, using the VFP OleDB driver (ensure you have the latest version). The connection string should point to the PATH where the .dbf files are located, then query from them by their name (you do not explicitly need the .dbf suffix) for your querying.

Is there an easy way to set up ASP.NET Membership tables in a custom Database?

ASP.NET Membership is just great as there are a ton of functionality right there to be used, and we don't need to change nothing at all.
We can even create our own Provider based on Membership database, and that give us infinite possibilities, like as I don't like the Question/Answer I just use an email that is sent with a reset link.
But this is all done with SQLEXPRESS .mdf file and I wanted to use my own Database for this so I can use SQL Server Enterprise as we have in the Office and not the Express Edition.
How can I easily use the ASP.NET Membership tables in my own Database?
I rememebered some years ago that we needed to use aspnet_reg (something) to create the correct tables, but I can't find that info anymore.
I also tried to use other Membership Providers, namely Altairis.Web.Security from CodePlex and saw the Chris Pels Video on creating a new Membership Provider
On Altairis solution, the Model is not complete and lack several points such as Several Applications as it's made to be used with only one, and Chris Pels contains to much Store Procedures that I need to create by hand.
I'm for given Chris code a go but I just wanted to know if there would be available something easier.
All this is to be integrated in ASP.NET MVC 2 Web Application.
Thanks
You have 3 options:
Do it by running aspnet_regsql.exe: Just open "Start Menu>All Programs>Microsoft Visual Studio 2010>Visual Studio Tools>Visual Studio Command Prompt(2010)" and then type aspnet_regsql. A wizard appears and let you select your desired database.
Do it via API: Use System.Web.Management.SqlServices class and its Install and Uninstall methods. This will programmatically install/uninstall database artifacts.
Do it manually: Go to C:\Windows\Microsoft.NET\Framework\v4.0.30319 or something like. You will find 9 .sql files that begins with Install and 9 .sql files that begins with uninstall. You can run them manually in your database to create needed tables/store procedures/etc. But consider changing database name in sql scripts. Default db name is aspnetdb.
It's aspnet_regsql
Under the following path:
C:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql
You need to open up the Visual Studio Command Prompt, navigate to C:\WINDOWS\Microsoft.NET\Framework\\aspnet_regsql.exe . Some example are located in the MSDN documentation.
Example: aspnet_regsql.exe -E -S localhost -A mr - installs the database elements for membership and role management on the local computer running SQL Server using Windows authentication.

SQL Server Linked Server error

I am using SQL Server 2008 on Windows Server 2003. I want to use a linked server to open a Visual Foxpro DBF file, using driver Microsoft OLD DB Provider for Visual Foxpro from SQL Server 2008 linked server feature.
When I establish linked server connection by using Microsoft OLD DB Provider for Visual Foxpro, to open a Foxpro DBF file, I meet with the following error, any ideas what is wrong?
Can not retrieve required data from this request (Microsoft.SqlServer.Management.Sdk.Src)
Meeting exception when executing Transact-SQL or batch (Microsoft.SqlServer.ConnectionInfo)
Error from Microsoft OLD DB Provider interface "VFPOLEDB" of linked server "DBFServer", access is defined.
Can not retrieved required interface "IID_IDBSchemaRowset" from OLE DB interface "VFPOLEDB" of linked server "DBFServer"
(Microsoft SQL Server error 7399)
regards,
George
Check 'Allow Inprocess' on the VFPOLEDB provider:
See Cindy Winegarden's answer on http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/e54d20dd-b65b-4cff-9349-6499e6e069e2 for how to do it.
Edit: this is the relevant part of the answer:
Here's what Stepahnie posted to her thread in the
microsoft.public.data.oledb NNTP newsgroup on April 10:
"Finally, I found an option ' Allow inprocess' in linked server ->
providers -> VFPOLEDB in MSSQL2005. With enable this option, I can
connect to vfp with oledb. While diabling this option, it works only
50% with successful connection....
And I have another MSSQL2005 with the same setup (except the option
'allow inprocess' disabled), all the connection make to vfp is 100%
successful... "
I looked and found that, as she said, in Server Objects > Linked
Servers > Providers > VFPOLEDB > General tab > Provider options >
Allow inprocess. Also, you can change the InProcess setting with the
following code:
USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'VFPOLEDB', N'AllowInProcess', 1
GO