Replication from Sybase SQL Anywhere to MSSQL - sql-server

I am trying to replicate or synchronize data between Sybase SQL Anywhere database with MSSQL db.
I tried Proxy Table in SQLA and insert query is working fine. But for actual replication we need update and delete. For that I used INNER JOIN remote database with SQLA db, but it shows error
update operation attempted on non-updatable remote query
. My Update query is below:
UPDATE Test
SET ID = S.accno, Name = S.particulars
FROM "DBA"."acc_ledgers" S
WHERE S.accno <> Test.ID
Update query on remote mssql database is working fine if no join or subquery is used. But when I join the SQLA table it gives error.
What is the problem in this? Can you suggest any solution or alternatives?
Thank you

Related

Delete Fails using ODBC in SSIS

I changed an Execute SQL Task targeting my default, local SQL Server instance from OLE DB to ODBC. The SQL is
delete from tablename
The ODBC version works fine when the table has records but fails when the table is empty.
I thought about using the result set of another SQL Task to populate a variable but that would not work. Reading this SO article Delete statement fails when called from SSIS identified the source of the problem (ODBC version), but it still didn't provide the answer. Other web articles suggested no workaround.
Are there any other methods or approaches to conditionally call the delete only if the table is not empty?.
It occurred to me to just use T-SQL to solve the problem. I used a T-SQL conditional statement which works fine. The ODBC SQL Task succeeds whether or not the table is empty.
if 0 < (select count(1) from tablename)
delete from tablename

Message "cross-database references are not implemented" for a simple query from SQL Server to PostgreSQL

I need to query PostgreSQL from SQL Server. I created a linked server connection (ODBC for PostgreSQL, the newest). It works on some schemas and not on the others. They're all on the same server.
For example this works:
SELECT * FROM LinkedPS.MyDatabase.Schema1.Table1
and this doesn't:
SELECT * FROM LinkedPS.MyDatabase.Schema2.Table2
I wasn't able to find any property which would cause this.

Access table that will link to a table on SQL Server, update when Access Data changes

I have an Access Database, which links in multiple Excel files as well as being connected to Google Analytics.
I created a Unison Query to bring all the files and tables into one Table.
I need this table to be accessible and refreshable by multiple other users, normally through an excel powerpivot table. I set up an Azure SQL server and did the export wizard to move the data over, which works but I cannot update it with new data (which I need to do daily). Simply sharing the access db won't work as not everyone has same file structures.
How can I get the table in Access to link to SQL, so when it is updated in Access, the table in SQL updates?
After exporting table manually to Azure SQL Server, simply link that very table into the MS Access application and then run action queries manually or automatically via code for your daily update.
Linked SQL Server Table
This is a well-known feature of MSAccess.exe, capable of connecting to practically any ODBC/OLEBD compliant data source from Oracle and SQL Server to Quickbooks and Salesforce. Requirements include:
Azure SQL Server ODBC Driver or a previously created Data Source Name (DSN)
Ensure connected user has read/write table privileges (assign on the server)
Walk through wizard for initial setup (see ODBC database option under External Data)
Action Queries
SQL (save as an MS Access stored query, can double click object to run manually)
Number of columns should be equivalent in INSERT and SELECT clauses and each corresponding type should match (leave out autonumbers).
INSERT INTO mySQLServerTable (Col1, Col2, Col3, ...)
SELECT e.Col1, e.Col2, e.Col3, ...
FROM myExcelTable AS e
Alternatively, if you need to run an UPDATE query requiring match column(s) between the two table sources.
UPDATE mySQLServerTable s
INNER JOIN myExceltable e ON e.MatchColumn = s.MatchColumn
SET s.Col1 = e.Col1, s.Col2 = e.Col2, s.Col3 = e.Col3, ...
VBA (automatic run of stored query inside MS Access)
' WARNS USER OF NUMEBR OF ROWS TO BE INSERTED/UPDATED
DoCmd.OpenQuery "myActionQuery"
' DOES NOT WARN USER
CurrentDb.Execute "myActionQuery", dbFailOnError
Conversely, you can run an SQL Server query that inserts into your table from the external MS Access source using OPENROWSET. This assumes the database is accessibly from where the SQL Server resides.
INSERT INTO INSERT INTO mySQLServerTable (Col1, Col2, Col3, ...)
SELECT e.Col1, e.Col2, e.Col3, ...
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'C:\path\to\myDatabase.accdb', 'admin', '', myExcelTable) AS e

How to See Actual Data Stored in Table Without Running SQL in SQL Server

I have a database in SQL Server 2012 as:
now can you please let me know how I can I see the actual data stored in the dbo.UserAccount table without running expicitly a SQL command like SELECT * FROM dbo.UserAccount ?
I tried by clicking on the table node but this just expand the collapse columns nodes.
You need to run SELECT ... FROM .... T-SQL is the only API to access SQL Server. You may learn that you can right click a table in SSMS and select 'view top 1000 rows' but that is really just opening a query and running a SELECT.

Data visibility between linked server

Please consider the following situation
I have Prod instance of SQL server 2012
Also Archive instance of SQL server express 2012
Prod sees Archive as linked server and is able to write data with similar query from some .net code that creates a transaction and the transaction is committed at the end.
insert into <ArchiveServer>.<database>.<schema>.<table>
Select * from <ProductionServer>.<database>.<schema>.<table> Where <some conditions>
Now after the transaction finishes I am able to execute the following query
select count(1) from <ArchiveServer>.<database>.<schema>.<table>
and it returns correct number of records in the context of production server.
Same query
select count(1) from <database>.<schema>.<table>
in the context of Archive server returned 0 records.
What might be the problem? I am out of clues.
Thanks

Resources