There are SQL Server 2008 R2 and PostgreSQL 9.2 under Windows (currently XP SP3). How can I query SQL Server from PostgreSQL? No problem when SQL Server->PostgreSQL via Linked Server.
Searching web I found odbc_fdw which is not possible to compile for 9.2.
Is there any working solution?
In addition to the standard but immature SQL/MED and foreign data wrappers mentioned by #vyegorov, the traditional solution to this problem has been DBI-Link, a set of foreign data mapping functions that use Perl DBI via plperl.
http://pgfoundry.org/projects/dbi-link/
There is a SQL/MED extension that describes how database can access external data.
PostgreSQL supports this part of the standard via the Foreign Data Wrappers. The linked page describes all (well, almost all I suppose) FDWs that are available now. I think that your finding on odbc_fdw are correct, but I admit, that it is not always straightforward to make FDWs working, especially on Windows.
You can take a look at Multicorn if you're familiar with Python.
Related
This is more of a "just wondering" question. Is there any way to access the Windows Indexing service database through ODBC in MS Access or SQL Server? I know there are a million recursive programming ways to traverse the file system but if I was only looking for files with a certain name I would think something as simple as "Select Fullpath from CDrive Where FileName like '%HEVC%'" would be easier and more lightweight than other methods.
I can't seem to Google this since all it does is return a million results for ODBC DSN creation.
Foreword: My focus is on other projects, but this is an interesting topic.
Microsoft uses an EDB file to provide a central Indexing Service - MSDN. Based on the Microsoft SQL Server CE engine, it is lightweight offers a number of methods for access including addition of third party file type definitions.
However, there are differences...significant ones that prevent direct translations of EDB and CEDB. Comparing EDB with SQL Server CE
As I said, there are access methods. The ODBC you were hoping for was discontinued after Windows XP.
However, Microsoft has developed two methods:
Windows Search (client side)
Microsoft Search Server Express (server side)
Both methods allow for quick file searches and likely could be integrated into whatever warehouse architecture you have through APIs, for example. However, there are limitations on methods that the links point out.
I admit I cannot give a full answer since I was learning, too, but hopefully this can point you in the right direction.
Cheers,
Actually, Found something else here:
Querying the Index with Windows Search SQL Syntax
Works like a charm, just have to get used to the special SQL syntax. Works on Windows 10, just having a problem querying a Storage Space. I'll update if I find an answer.
I have a scenario where I get queries on a webservice that need to be executed on a database.
The source for these queries is from a physical device so I cant really change the input to my queries.
I get the queries from the device in MSSQL. Earlier the backend was in SQL Server, so things were pretty straight forward. Queries would come in and get executed as is on the DB.
Now we have migrated to Postgres and we don't have to the option to modify the input data (SQL queries).
What I want to know is. Is there any library that will do this SQL Server/T-SQL translation for me so I can run the SQL Server queries through this and execute the resulting Postgres query on the database. I searched a lot but couldn't find much that would do this. (There are libraries that convert schema from one to another but what I need is to be able to translate SQL Server queries to Postgres on the fly)
I understand there are quite a bit of nuances that will be different between SQL and postgres so a translator will be needed in between. I am open to libraries in any language(that preferably runs on linux : ) ) or if you have any other suggestions on how to go about this would also be welcome.
Thanks!
If I were in your position I would have a look on upgrading your SQL Sever to 2019 ASAP (as of today, you can find on Twitter that the officially supported production ready version is available on request). Then have a look on the Polybase feature they (re)introduced in this version. In short words it allows you to connect your MSSQL instance to other data source (like Postgres) and query the data in as they would be "normal" SQL Server DB (via T-SQL) then in the background your queries will be transformed into the native pgsql and consumed from your real source.
There is not much resources on this product (as 2019 version) yet, but it seems to be one of the most powerful features coming with this release.
This is what BOL is saying about it (unfortunately, it mostly covers the old 2016 version).
There is an excellent, yet very short presentation by Bob Ward (
Principal Architect # Microsoft) he did during SQL Bits 2019 on this topic.
The only thing I can think of that might be worth trying is SQL::Translator. It's a set of Perl modules that have been around for ages but seem to be still maintained. Whether it does what you want will depend on how detailed those queries are.
The no-brainer solution is to keep a SQL Server Express in place and introduce Triggers that call out to the Postgres database.
If this is too heavy, you can look at creating a Tabular Data Stream (TDS is SQL Server network transport) gateway with limited functionality and map each possible incoming query with any parameters to a static Postgres query. This limits any testing to a finite, small, number of cases.
This way, there is no SQL Server, and you have more control than with the trigger option.
If your terminals have a limited dialect demand then this may be practical. Attempting a general translation is very likely to be worth more than the devices cost to replace (unless you have zillions already deployed).
There is an open implementation FreeTDS that you could use if you are happy with C or Java.
I'm looking for a way that I can keep a database in one single file, no server hosting it, and with the ability to use ADO (In delphi, specifically TADOConnection and/or TADOQuery). Please pardon my lack of terminology on this one. I'm only familiar with SQL Server databases, and nothing about any others. In fact, the only other ways I know to read/write files are Plain Text, INI, and XML. As for any official "databases", I know nothing.
So what I would like to do is keep a single file as a database, similar to how QuickBooks has a single "Company File". I should not have anything to host the data, such as SQL Server. And it needs to be compatible with ADO, so I can use simple select, update, delete, etc. It doesn't need to be so complex as to have relations, security, etc. But it does need to have some same syntax rules as SQL Server, like commands such as join, alter, distinct, etc.
I'm looking for the lightest-weight method to do so. The files need to be flexible enough to be able to copy/paste (so long as the application isn't using it), similar to an excel file. In fact, my original idea was to use Excel, as I know I can use ADO, but I also don't want to require Microsoft's excel drivers (it would have to presume that MS Office / Excel is installed on user's computer). It's obviously going to need some drivers, but I need the most standard method which is compatible everywhere.
You can use MS-Access MDB files. It can be used via Microsoft OLEDB Jet 4 engine (Which is build in into Windows since at least Win XP) and is perfect for local desktop DB applications, with the ability to create Tables, PKs, Indexes, Queries/Views, Transactions, Multi-User, replication, compact/repair and much more with almost perfect compatibility to MS SQL-Server SQL syntax (since MS-Access is the ancestor of MS SQL-Server).
MS-Access product (i.e MS Office) dose not have to be installed on the client machine.
No extra drivers or files to install, and completely integrable with existing MS-Office products.
Edit: MDB files could be also Protected/Encrypted.
You have several options for store your data in single database file.
SQLite
Firebird
Interbase
All of them can be accesed via ADO using a ODBC or OLEDB driver. my personal recomendation is Firebird, because is free, fast, stable and had a Embedded version.
This is a pretty useful comparison of a number of embedded databases. Of the ones tested these ones support (odbc), (oledb) or (both) and use a (single) file for the database:
Accuracer (odbc) (single)
NexusDB (odbc) (single v4 and newer)
Firebird (both) (single) - multiple odbc implementations and the commercial IBProvider supports three different ways to connect to the ADO components.
TurboDB (odbc) (single v4 and newer)
Note: Most of these also supply ADO.Net Providers as well.
The other's in the comparison (Advantage, ElevateDB, DBISAM and Apollo) use a file per table/index scheme.
I have a large (100+ tables) SQL Server 2005 database that I would like to start mapping with Doctrine. Right now I've done a manual job of a few tables (no relations yet, just disparate tables), using PHPDOC annotation mapping inside my entities. Manually it works like a charm ... however it really will take ages to get everything mapped out and I'm looking for an easier way.
I looked into ORM Designer, but it doesn't seem to offer imports from a SQL Server database. I also looked at using Doctrine CLI and doing the "reverse engineering" mentioned here. Finally tried using orm:convert-mapping --from-database with no luck. It appears the last two are conditional on the fact that the sqlsrv drivers (running on IIS7 here) cause an error on my tables when they have no index: PDOException: The active result for the query contains no fields.
Is it possible that I can load up Doctrine on an Ubuntu machine, and use whatever drivers Linux has to connect to SQL Server 2005 ... then perhaps the orm:convert-mapping feature wouldn't die on me?
Any help would be much appreciated!
Try with this drivers for php. (clue: non thread safe)
Also check your connection parameters.
I worked on a SQLServer 2005 express project with Symfony2 and I mapped all my tables in reverse with no trouble at all.
Well, actually had to implement a new doctrine type for datetime as it says here.
Good luck!
Looks like the TSQLConnection only connects to existing databases, and I could not find another component that allows me to send commands to the database server.
I'm using Delphi 2009 with Firebird and MSSQL.
One idea that came was to connect to a system database (master or tempdb in MSSQL for example) and then send create commands to the server. This could be an option for MSSQL, but I'm not sure for Firebird.
I'm also aware of the new DBX metadata in Delphi 2009, but I couldn't find a way to create databases using it. All examples I've found is to modify existing databases.
Yes, you can. dbExpress now includes a powerful set of meta-data classes for doing just that.
Steve Shaughnessy gives a good introduction here.
Erick if you use Devart drivers you can connect without the databasename parameter and send the t-sql create database command.
dbExpress included in Delphi uses a "least common denominator" strategy. Information like query statistics which is available through native drivers is invisible with dbExpress. (Maybe I should ask a question like "Which feature in alternative dbExpress implementations made you switch?")
You can execute "CREATE DATABASE ..." on both databases with standard TSQLQuery.
Note that syntax differes between these two. Since dbx is lightweight lib, this SQL and DB specific action probbably will never be fully supported. It leaves you with SQL.
With Delphi 2007/2009 comes DBX4. You may use the low level structures there to create database programmatically. Look in dbxcommons.pas
You can send a "CREATE DATABASE" script through any connection (ADO, OLEDB, ODBC, etc) opened on any server (or even ms-access files) as long as it follows the specific server DDL syntax.