Postgres database sync missing left sibling - sql

I'm currently trying to compare/sync two databases, sync the changes from the test DB to the live DB. Both are running Postgres 9.1 and the test DB was a dump of the live one.
When I try a compare/sync with a program like "Navicat" or "SQL Management Studio", I get the error:
Error: ERROR: could not find left sibling of block 176 in index
"pg_attribute_relid_attnum_index"
I searched and googled, but I don't really understand what the problem is.
Also when I make the DB select in both databases:
SELECT * from pg_attributes
It doesn't show any problem. Any ideas? Thanks in advance!

Related

Unable to Run Update Query in SQL Azure *Invalid object name 'DataSync.provision_marker_dss'.*

I was syncing my Azure SQL Database with On-Premises SQL Database which created a lot of tables in the Online database (As Usual). Anyway, It was working fine.
Now, I had to re-create the Azure SQL Database. So, I deleted the Sync Group & Sync Agent as well.
Everything's working absolutely fine unless I run an Update Query on that database.
Whenever I run Update Query on some of the tables, the database shows the following error.
Msg 208, Level 16, State 1, Procedure finstock06_dss_update_trigger,
Line 9 Invalid object name 'DataSync.provision_marker_dss'.
There is no such table I ever created on the database.But it's name shows that it was one of the automatically created tables while syncing. (But why here? I have re-created the database)
Although, I created all the tables again on new database but facing this issue.
Any help would be appreciated.
Thanks
I had no sync groups left, and deleted all DataSync tables, but still got the error.
Triggers had to be deleted manually too:
https://richardjgreen.net/repairing-damaged-sql-azure-sync-group/

same query from remote server and on server, different results

I have a server called ERP-SERVER, and a server called SQLDEV-SERVER.
They both have a blob instance, but we never copy over the complete blob to the SQLDEV-SERVER as that would be too much data.
So when trying to access a file on our test server, it should first check if that file exists on the SQLDEV-SERVER, and if not check if the file exists on the ERP-SERVER. This is where it goes wrong. This piece of code (SQL) used to work but somewhere along the way it broke. I have narrowed it down to the inter database query just returning completely different results.
so for instance i run this query on the ERP-SERVER instance in SQL management studio:
SELECT count(*)
FROM [erp-server].[Extranet_Blob].[dbo].[FileStorBlob]
this returns 223221 results.
When i run the same query on the SQLDEV-SERVER instance in SQL management studio, it returns 313 results.
It points to the same server and same database, yet a completely different count, which is why it is also not returning the files from the live environment when it is not found on the dev environment.
Any pointers as to where this problem could be situated?
Look very carefully at your linked server definition. When you are running the query on SQLDEV-SERVER it is using the linked server definition of that name rather than necessarily the ERP_Server. Is it possible that someone has fiddled with the definition?

"Select data source" popping-up when executing a SQL writed query

I try to create a pretty complex database on ms Access 2013, so I wanted to type it directly in SQL. It has no errors, as other DBMS can fully build the database from the script I wrote (for example, phpmyadmin imports it with no difficulty).
On this tutorial, it is showed how to write a SQL query in order to build tables. I thought this way matched well with my goal as I could copy-paste my script in the query and run it to create the whole thing.
But when I tried to open/double-click on the query a pop-up appears saying "Select data source", waiting for me to select an ODBC, either from a file or a host, before continuing and executing the query.
I tried other types of queries (creating only one table at time, trying on a blank file, or even SELECT * FROM *), bt this message keeps showing up and I really don't know how to deal with it as I don't want to connect to anything but the infile database.
Does anyone got a hint about what to do in this case?
Or, even better, how could Access import my SQL script in order to create the database?
You should configure the database connection in the ODBC and check whether the connection is established or not. Once the connection is established, you can run the query to fetch the data or create tables as per your requirement.

Oracle Database Users in synced database

Ok so I have a little problem...
In my project we have a Oracle SQL Server. In the database I have access to some of an other users tables:
Tables:
|-bla
|-bla
Users:
|-otherUser (let's just call him that)
|-Tables:
|-aTable
In Oracle, to access the aTable table I use SELECT * FROM otherUser.aTable
Now, we also have a MS SQL CE database to which I sync the data from the OracleDB using the MS Sync f/w. And in the CE db - after sync - I get a table otherUser.aTable. This sounds good, so even though the CE doesn't have the User concept it just adds the same table.
BUT the problem is that when calling the same SQL query on CE as on Oracle I get a The table name is not valid error. Instead if I want to get the content of the table, the two ways that I have found to work is surrounding the otherUser.aTable with either [] or "".
However neither of them seem to work with Oracle. The [] seem to be an illegal name, and the "" seem to search for a table called just that (not an other user).
So why don't I just use the one way on Oracle and the other on CE? well I also use NHibernate as a ORM and it kind of needs the same table name for both the databases...
Is there a third way to encapsulate the table name that works with users in Oracle and just works in CE? or do you have any other ways to fix this issue?
I have no experience with MS SQL, but it seems like a problem that might be solved with synonyms on Oracle side.
Try to create synonym "otherUser.aTable" for otherUser.aTable in Oracle.

How do i get the names of all the tables inside a database?

EDIT2: Found a fix! I used the number of the desired schema instead of the name. Should've thought of that before, really! And i think the error messages could've been a bit better aswell. Thanks for all your time!
How can i get the names of all tables inside a database through sql inside asp classic?
The server is running windows 2008, iis7.5 and microsoft jet. I've tried all the querys i could find on the internet (and here) but none have worked.
If i add a ; to the query to run a set of querys at the same time it gives me an error because the statement isn't over at the semicolon.
The master.mdf database cannot be accessed because it's of unknown format.
The sysobjects variable apparently doesn't exist.
I am using mssql 2000 format. (.mdf)
The connection is made through classic asp with the Microsoft.Jet.OLEDB.4.0 provider and ADODB connection/recordset.
How do I get list of all tables in a database using TSQL?
Query to get the names of all tables in SQL Server 2008 Database
EDIT:
I've found two folders containing databases. One is in C:\program files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\mssql\binn\templates and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, msdbdata.mdf and msdblog.ldf. The other one is also in the \binn\template data directory and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, MSDBData.mdf, MSDBLog.ldf, mssqlsystemresource.ldf, mssqlsystemresource.mdf, tempdb.mdf and templog.ldf. Maybe these is of some interest?
How can i tell if i have permission? Does it give a permission denied error?
Please help! No, don't. Read the 2nd edit at the top.
USE YOUR_DATABASE
GO
SELECT *
FROM sys.Tables
GO
Have you tried the example from:
http://www.kamath.com/codelibrary/cl002_listtables.asp
I almost always use the INFORMATION_SCHEMA views:
SELECT * FROM INFORMATION_SCHEMA.TABLES
If this isn't working for you, the SQL user your site is running under may not have access to the system objects. This is actually a good thing, as giving your site access to the underlying database schema can leave you vulnerable to SQL injection.
So if you do go this route, proceed with caution.
The mdf by itself is useless: you need a database engine (a.k.a. a SQL Server instance) to "run" it. As I understand the question, this is your problem.
Then you can use sysobjects in your database: unless you have added your tables to the master database
There is no practical way to use an mdf directly: if nothing else download MSDE