SQL Query to import data from 50 Access ACCDB databases - sql

I am new to SQL, so please forgive my ignorance. I downloaded the free version of SQL Server Express Edition 2014 and have a 32 bit machine. I'm using Microsoft SQL Server Mgmt Studio. I am trying to setup a process to either link to or import 50 Access tables that are in 50 individual Microsoft Access 2013 databases (updated weekly) into SQL. I currently do this in an Access 2013 db but I am trying to replace the process. I downloaded the free version of SQL Server Express Edition 2014 and have a 32 bit machine. I'm using Microsoft SQL Server Mgmt Studio on my PC. Below is the code I put together. however, this is the result in the message window:
Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
Configuration option 'Ad Hoc Distributed Queries' changed from 1 to 1. Run the RECONFIGURE statement to install.
Msg 7403, Level 16, State 1, Line 8
The OLE DB provider "Microsoft.Jet.OLEDB.12.0" has not been registered.
I am a newbie so I would greatly appreciate no assumptions in knowledge. Thank you.
sp_configure 'show advanced options', 1;
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE WITH OVERRIDE;
GO
INSERT INTO TEST2.dbo.MyTest
SELECT * FROM OPENDATASOURCE(
'Microsoft.Jet.OLEDB.12.0',
'Data Source="D:\data\EXCEPT2.accdb"')...Testtbl;
GO

Turns out I had to run the below code to get the sql to work. I also had changed 'Microsoft.Jet.OLEDB.12.0', to 'Microsoft.Jet.ACE.12.0',
USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO

Related

Azure - Enable/Disable database setting for security purposes

We have certain security requirements in order for our app to go live within our orgainisation.
We are using the Microsoft azure platform to host the application along with a Azure SQL server and database. To meet these security requirements, we need to configure settings on the server/database.
However we are running into issues using the default azure SQL server/database.
Here is an example. We need to "Disable 'clr enabled' option".
We have tried the following:
EXECUTE sp_configure 'show advanced options', 1;
RECONFIGURE;
EXECUTE sp_configure 'clr enabled', 0;
RECONFIGURE;
GO
EXECUTE sp_configure 'show advanced options', 0;
RECONFIGURE;
We run this in the T-SQL editor on the Azure platform, and receive the following:
Failed to execute query. Error: Statement 'CONFIG' is not supported in this version of SQL Server.
When we run the following, we see that is enabled.
SELECT name,
CAST(value as int) as value_configured,
CAST(value_in_use as int) as value_in_use
FROM sys.configurations
WHERE name = 'clr enabled';
How to we update these settings?
thanks.
sp_configure (Transact-SQL) is not supported in Azure SQL database:
We can not run the sp_configure statements. But sys.configurations (Transact-SQL) table is supported.
We can see the default value is 1 for clr enabled.
And like #Larnu said, CLR is also not supported: Resolving Transact-SQL differences during migration to SQL Database.
Ref this question: Does or does not SQL Azure support CLR assemblies?
Just for now, we can not change this settings in Azure SQL database.
HTH.

Schedule query in SQL Server 2014 Management Studio

I am trying to schedule a SQL query in SQL Server 2014 Management Studio.
For some reason I am unable to find SQL Server Agent (i.e. to expand Jobs to create Schedule).
Is there a new way to schedule SQL query on SQL Server 2014?
Thanks
You can use Windows Task Scheduler to run your SQL query.
Follow below link to creation and deployment of task.
Click here to create windows task
SQL Server Express does not include SQL Server Agent. Editions higher than that (such as Standard, Enterprise/Developer) do.
If your edition supports SQL Server Agent, make sure it is installed.
If it is installed, you may need to configure it before you see it show up as available in SSMS.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO
source
This is for the most basic configuration, without regard to permissions and such. For that, it's probably worth reading this short overview.

How to access Database from other computer using sql query in sql server

I am using a SQL database residing on my local computer. I want to access a table from a database residing on another computer using SQL query.
I have been able to connect the remote database with my database and all its tables are shown in Enterprise manager on my local machine. I have added remote SQL Server in my local SQL Server.
When I use select statement in my local SQL server it gives the message database does not exist or access denied.
Any help in this would highly be appreciated.
EDITED
Select * from [ServerName].DatabaseName.dbo.tableName
Use OPENROWSET
Example
SELECT t.version FROM
OPENROWSET('SQLNCLI', 'server=Myserver;UID=xxxx;pwd=yyyy',
'select ##version version') t
Note:
SQLNCLI is the name of installed OLE DB provider
Datasource: {server=Myserver;UID=xxx;pwd=yyy}
You have to enable OPENROWSET by executing the following script:
sp_configure 'show advanced options', 1
reconfigure
go
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
OPENROWSET is like connecting to a linked server

SQL Server 2008 connecting to instance is not working

I am trying to deploy my database on a customer server
I tried this:
select ##servername
and I got this
`INCONCERTSERVER`
Then I tried to create this stored procedure:
CREATE PROCEDURE [dbo].[getAgentStatues]
AS
BEGIN
SET NOCOUNT ON
EXECUTE sp_configure 'Show Advanced Options', 1
RECONFIGURE
EXECUTE sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
SELECT UserName, LoggedState, InteractionId, InteractionType --<-- The columns required.
FROM
OPENROWSET('SQLNCLI'
,'Server=INCONCERTSERVER;Trusted_Connection=yes;database=MMProDat'
,'EXECUTE dbo.[SupGetAgentsWithInteractions]')
END
I got this error:
OLE DB provider "SQLNCLI10" for linked server "(null)" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "(null)" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
Msg 53, Level 16, State 1, Line 0
Named Pipes Provider: Could not open a connection to SQL Server [53].
Could you help me please?
I am already using a windows admistrator accound and an administrator on the database
I am working remotely using remote desk top
Try something like this....
CREATE PROCEDURE [dbo].[getAgentStatues]
AS
BEGIN
SET NOCOUNT ON;
SELECT UserName, LoggedState, InteractionId, InteractionType
FROM
OPENROWSET('SQLNCLI'
,'Server=INCONCERTSERVER;Trusted_Connection=yes;database=MMProDat'
,'SET FMTONLY OFF;SET NOCOUNT ON;EXECUTE dbo.[SupGetAgentsWithInteractions]')
END
Execute Proc
EXECUTE sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
EXECUTE sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
EXECUTE [dbo].[getAgentStatues]
GO

Openrowset on SQL Server 2008 R2 installed in Windows 2008 64 bit machine

I'm trying to working with Openrowset on SQL Server 2008 R2 installed in Windows 2008 64 bit machine.When I execute the below query, i got an error like below.Please help me out.
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\01112012.xls;','SELECT * FROM [Sheet1$]')
ERROR:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.
Have you installed: ->Microsoft Access Database Engine 2010 Redistributable
This download will install a set of components that facilitate the transfer of data between existing Microsoft Office files such as Microsoft Office Access 2010 (*.mdb and .accdb) files and Microsoft Office Excel 2010 (.xls, *.xlsx, and *.xlsb) files to other data sources such as Microsoft SQL Server. Connectivity to existing text files is also supported. ODBC and OLEDB drivers are installed for application developers to use in developing their applications with connectivity to Office file formats.
To run OPENROWSET in 64 bit version of windows.
1- Install AccessDatabaseEngine_x64.exe (Restart is required).
2- If you are using SQL Management Studio, run Management Studio as administrator. If you don’t run it as an administrator account you will have this error (Cannot initialize the data source object of OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)".
3- Run this command to configure your Database
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE with override;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE with override;
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
GO
4- Don’t use ‘select * from sheet1$’ in OPENROWSET function. Try this code.
select * from OPENROWSET('MICROSOFT.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;DATABASE=D:\test.xlsx', sheet1$)
If still you have (32 bit) error, try to restart your SQL service and check your C:\Windows\Temp and see do you have access to this directory or not.