I have 2 server, the server1 (PostgreSQL) is our integrator and the server2 (Azure SQL Server) is for our enterprise.
So I try to extract tables from server1 and copy them to server2 for our ETL.
To not do that every day, I want to extract only rows that I don't already extract. In terms of SQL code, I try to do something like that:
select *
from server1.database1.MyTable
where not exists (select * from server2.database2.Mytable)
The issue is this SQL query doesn't work, I get this error:
SQL Error [40515] [S0001]: Reference to database and/or server name in 'server1.database1.MyTable' is not supported in this version of SQL Server.
Thanks for your help!
Related
I have an application that is directly connected to Postgresql database, I need to retrieve certain values from an external SQL Server database.
Is there a way I can send a select statement to SQL Server from postgresql, and get back the results?
yes - you can use foreign table on MS SQL Server
https://www.mssqltips.com/sqlservertip/3663/sql-server-and-postgresql-foreign-data-wrapper-configuration-part-3/
https://github.com/tds-fdw/tds_fdw
I am trying to copy 2 databases from SQL Server 2012 to a new VM SQL Server 2017.
One of the databases was restored successfully but the other is giving me the below issues.
Databases both restored successfully, however 1 of the databases when I try to access the tables I am getting this error in SSMS "data is null this method or property cannot be called on null values"
Appreciate any help.
SQL Server 2017 has numerous features that aren't present in SQL Server 2012 and it is likely your version of SSMS doesn't support the newer version of SQL Server.
It's probable that when you open the database in SSMS it is trying to load Database Diagrams (now deprecated).
Are you able to run:
USE [databasename]
GO
SELECT * FROM sys.objects
and see if your expected tables are in there?
In SQL Azure, I try this:
select * From master.dbo.sysdatabases
And get this error:
Reference to database and/or server name in 'master.dbo.sysdatabases' is not supported in this version of SQL Server
What should I do to be able to run that query in SQL Azure?
You use the system view sys.databases (without the master qualification, it is not needed)
The system table sysdatabases has been deprecated since SQL Server 2005 (Azure is a later version) and in any case is not supported on Azure
You are getting this error because you are running this statement from another database than master. You cannot add "master." to your statements unless you are already on the master database. More generally speaking, you cannot issue statements that execute a command on another database than the one you are on.
You can run the statement without the database qualification, and it will run, as gbn is suggesting. Or you can connect to master and execute it as-is.
I created a database in SQL Server 2008. I detached the database and I copied the .mdf over to the server, which is running SQL Server Enterprise Manager (SQL Server 2000).
When I try to attach the MDF I get...
Microsoft SQL-DMO (ODBC SQL State: HY000) Error 602: Could not find
row in sysindexes for database ID 13, object ID 1, index ID 1. Run
DBCC CHECKTABLE on sysindexes.
What does this mean? Is this because the db was created in a newer version?
From the documentation on the (I believe depreciated, but used in SQL Server 2000) sp_attach_db stored proc:
A database created by a more recent version of SQL Server cannot be
attached in earlier versions.
I think you'll have to script the schema and data of your database.
Pinal Dave has a good tutorial on how to do this here - just remember to make sure you choose the following settings:
Under General:
Script for server version: SQL Server 2000
Under Table/View options:
Script data: True
Remember to double check the settings for any others you might be interested in, such as foreign keys, triggers etc.
This is do-able, but you'd need to convert it to the SQL 2000 format before detaching it and attaching it on the old server. Here are the steps:
In entreprise manager, right click the database
Choose properties
On the left, click Options
Change the "Compatibility Level" to SQL Server 2000 (80)
Then save, and detach before reattaching on the old server.
I'm trying to upgrade a database from a SQL Server 2000 instance to a SQL Server 2008 instance. I'm doing this by right clicking on the database and selecting copy database. My current issue is that I'm getting this error in the log file:
OnError,AQUE-SQLDEV,NT
AUTHORITY\SYSTEM,aque-db2000_aque-sqldev_sql2008_Transfer Objects
Task,{F0ACDE4D-D023-400C-BE3C-91CD3A537988},{40E67169-0F3F-4F86-AD2E-6E2CB532BA5C},18/10/2011
15:38:37,18/10/2011 15:38:37,0,0x,Script failed for User 'WebUser'.
StackTrace: at
Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection
depList, SqlSmoObject[] objects) at
Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(SqlSmoObject[]
objects) at
Microsoft.SqlServer.Management.Smo.Transfer.Microsoft.SqlServer.Management.Common.ITransferMetadataProvider.SaveMetadata()
at
Microsoft.SqlServer.Management.Dts.DtsTransferProvider.Configure(ITransferMetadataProvider
metadataProvider) at
Microsoft.SqlServer.Management.Smo.Transfer.GetTransferProvider()
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData() at
Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
InnerException-->Creating a user without an associated login is not
supported in SQL Server 2008.;
Does anyone know why this might be happening?
Thanks,
Sachin
Based on the error it sounds like you need to create a login first on the SQL 2008 server that matches the same login/user that exists on the SQL 2000 server. You could do a couple of things:
create a new database in 2008 to migrate to
create a new login in 2008 that matches the existing login from sql 2000
map the new login to that new database from step #1
run the copy database wizard
If it was me, I would do as marc_s suggested and perform a full backup of the existing database on sql 2000, then restore to a blank database in sql 2008. If you can, update the compatibility mode in database properties to be 2008. I've done this hundreds of times and works like a charm.
The reason can be that a file with the new Database name already exist on the filesystem. We encountered this when we renamed Database X to X_Old, and tried to copy database Y to X. This cannot be done, because database X_Old is still associated with the filename X.
Either delete the conflicting database, or rename the file on the file system.
See http://codecopy.wordpress.com/2012/01/03/error-while-copying-a-database/