PostgreSQL TDS_FDW connection to pull in SQL Server metadata - sql-server

Creating a metadata repository in PostgreSQL but am having difficulty with TDS_FDW and attempts to import SQL Server's INFORMATION_SCHEMA tables.
Using tds_fdw version 2.0.0-alpha.3
When I try to import "master", TDS_FDW produces a syntax error:
postgres=# IMPORT FOREIGN SCHEMA master FROM SERVER sql002 INTO public OPTIONS (import_default 'true');
ERROR: syntax error at or near ")"
LINE 2: ) SERVER sql002`
If I run a test import schema using dbo, it works fine, but INFORMATION_SCHEMA doesn't exist
What would be a functional way to pull the database and column names from SQL Server into PostgreSQL? (It's been ages since I was a SQL Server dba)

Related

SQL Server select from linked server throw error if user has "deny view definition"

I have users with datareader permission on my sql, the problem is that i noticed that the users are doing "fishing" query a lot (they don't know what exactly should be querying to get what thy need).
This is a production SQL and we started to have deadlock because of those users.
Trying to don't break their process i applied "deny view definition to [user]" so they cannot see the list of tables, view, stored procedure, so no more "fishing"
This was a great solution, it works perfect if you connect directly to the SQL Server, you can run queries (select) but you cannot see the list of tables.
However many users are using those account to connect to our SQL using linked server, and when the run a query using the linked server they are getting error:
SELECT TOP 100 *
FROM [SERVERSQL].[DATABASE].dbo.[TABLE]
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI11" for linked server "SERVERSQL" does not contain the table ""[DATABASE]"."dbo"."[TABLE]"". The table either does not exist or the current user does not have permissions on that table.
Using SQL Server version 2014 (v12.0.2000.8) and 2016 (v13.0.5492.2).
What is the correct way to hide tables, view, stored procedures, etc but allow select and make it work on linked server?
Thanks
Linked server from one SQL Server to Another:
Linked server name is: PLWNSAVSQL02D which is SQL Server
This sql to linked server works:
select count(*) from [PLWNSAVSQL02D].[SFI_WMS].dbo.[TCOMPANYPALLETMESSAGES];

Import table from Windows SQL Server 2012 to hadoop using sqoop

I was trying to import a table from RDBMS (Windows - SQL Server 2012) to HDFS using the code below. But I'm getting an error. I could successfully connect it.
sqoop import
--connect
"jdbc:sqlserver://192.1x8.xx.1:14xx;database=AdventureWorks2012;
username=hadox;password=hadxx"
--table Production.Product
--hive-import
I understood the error was caused by the dot (.) in the tables name.
I got that information from the link sqoop to import data to hive. I didn't understand any details in that link.
Can anyone help please?
Thanks in advance.
Error:
ERROR manager.SqlManager: Error executing statement com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'Production.Product'.
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'Production.Product'.
Internally sqoop will consider Production as schemaname (database name) Product as the table name.
if you want to use import the table into production database, product table in hive. I would suggest you to use --query in sqoop command using that you are specifying the sqoop to look for specific table.

How to add Sybase SQL Anywhere DB as linked server to MS SQL Server properly

I used the Microsoft OLE DB Provider for SQL Anywhere to create a linked server, it shows remote databases and tables, I can read data, but writing data seems to work only using OPENQUERY() and when doing the connection_authentication using EXEC ... AT ... directly in the script.
How can I have the SQL Server do the authentication automatically when opening a connection?
How can I make normal write operations work without OPENQUERY()?
Sorry for not adding detailed error messages, I will add them later maybe, when I have access to the server again... But they were not meaningful anyway, i.e. when the weird authentication was missing, it just said "could not insert" or "failed" instead of indicating any authentication issue.
How to get the real error messages that come from Sybase?
Details:
SAP Sybase SQL Anywhere 16 (OEM Authenticated Edition) <-> MS SQL Server 2014
EXEC 'SET TEMPORARY OPTION CONNECTION_AUTHENTICATION=''Company=...''' AT linkedserver
INSERT INTO OPENQUERY(linkedserver, 'SELECT column FROM table WHERE 0=1') VALUES ('')
...that's not nice.
Even more details:
This is how I created the linked server
This is the authentication I'm talking about

Cannot import SQL Azure bacpac to 2016 CTP

I'm very familiar with the process of exporting from Azure SQL V12 down to my dev box and then importing to my local sql (2014) instance. I'm spinning up a new Win10 box and have installed the SQL 2016 CTP. I'm connecting to that same Azure instance and can operate against it -- and can export a .bacpac just as with 2014.
But when I try to import to local I'm getting:
Could not import package.
Warning SQL72012: The object [FOO33_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [FOO33_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 547, Level 16, State 0, Line 3 The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_dbo.Address_dbo.User_idUser". The conflict occurred in database "FOO33", table "dbo.User", column 'idUser'.
Error SQL72045: Script execution error. The executed script:
PRINT N'Checking constraint: FK_dbo.Address_dbo.User_idUser [dbo].[Address]';
ALTER TABLE [dbo].[Address] WITH CHECK CHECK CONSTRAINT [FK_dbo.Address_dbo.User_idUser];
Since this question was also asked and answered on MSDN, I will share here.
https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted
Text from linked answer:
I suspect what's going wrong here is that the export operation was performed using a DB instance that was changing while the export was on-going. This can cause the exported table data to be inconsistent because, unlike SQL Server's physical backup/restore, exports do not guarantee transactional consistency. Instead, they're essentially performed by connecting to each table in the database in turn and running select *. When a foreign key relationship exists between two tables and the read table data is inconsistent, it results in an error during import after the data is written to the database and the import code attempts to re-enable the foreign key. We suggest using the database copy mechanism (create database copyDb as copy of originalDb), which guarantees a copy with transactional consistency, and then exporting from the non-changing database copy.

ogr2ogr to import GML with spatial and non-in SQL Server

I am trying to use ogr2ogr to import GML file into SQL Server Spatial. I successfully import features with geometry, but I have few without geometry column. How can I import all of them?
EDIT:
I reinstalled GDAL, installed latest, works fine, but again cann't write non-spatial features.
Constantly getting error:
ERROR 1: Error creating layer: [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near 'NULLCONSTRAINT'.
The error looks like incorrectly formed SQL statement, created by ogr2ogr against the SQL database.
Have you tried running SQL Server Profiler (within SQL Server) whilst you do the import? Assuming you run a standard trace, you will need to locate the row with NULLCONSTRAINT in the textData column in the trace output. Once you have found the problem statement, this should give you some idea how to fix the problem.
If you need a very simple tutorial on the Profiler this link might help
http://www.mssqltips.com/sqlservertutorial/272/profiler-and-server-side-traces/
A similar error for me was caused by square brackets in the shapefile name I was importing which meant the create table statement was invalid.

Resources