Migrating access to SQL Server - sql-server

I've been asked to supervise the migration from an MS Access database to SQL Server. The tool being used is SSMA for Access.
During the progress we have been facing an issue
Synchronization Error: The foreign key cascading '[table name]' can not be created where the column reference '[table name].Codigo' is an identity column.
Is there any way to solve this without altering the structure of the table? We are facing this problem on multiple tables and it'd take ages to change the structure of the all.
Thanks in advance

You could shut off the identity checking by
SET IDENTITY_INSERT [table name] ON
Do your insert into SQL and then
SET IDENTITY_INSERT [table name] OFF

Related

Not able to perform Upsert for SQL Server Management Studio as the data contains Identity column in ADF

Not able to perform Upsert in SQL Server Management Studio(SSMS) as the data contains Identity column Sequence number & Rowid.
I am trying to perform incremental load from DB2 to SSMS. In the sink side I am selecting Upsert but throwing the error as:
Can not update identity column
I should not use dataflows to achieve this scenario.
Can anyone suggest how to do this for many tables dynamically to set the identity flag to
Yes if there is insert else I need to set identity flag as No?
Thanks in advance
I tried with set identity_insert dbo.test on to insert manually for one table
but need help to set up this dynamically.
ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed. Please search error to get more details.,Source=Microsoft.DataTransfer.ClientLibrary,
''Type=System.Data.SqlClient.SqlException,Message=Cannot update identity column 'SEQNR'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=8102,Class=16

Oracle ADF Insert operation set SQL Server database to use database auto increment PK

I am making a simple CRUD application using Oracle ADF with SQL Server database.
My problem is that when inserting a new record into SQL Server table, I get an error on the primary key. My table has a primary key as Auto_Increment, but ADF is having problems to respect the database to do its own Auto_increment how do you go about this. I am sure there is a simple solution that works but I cant find one.
Regards
Xavier

Sql Server 2008 >> msdb.dbo.sysmail_sentitems

Can anyone please tell me the name of Master table used by sqlserver 2008 to store dbmail information?
I tried to truncate "sysmail_sentitems" table but it gives me foreign key constraint violation error. Please reply if anyone knows.
You are trying to truncate sysmail_sentitems which is a view, I doubt that possible.
Master table used by sqlserver 2008 to store dbmail information is msdb.dbo.sysmail_mailitems.
I navigate through SP_Helptext sysmail_sentitems which give another view sysmail_allitems. Using SP_Helptext sysmail_allitems gives me a table sysmail_mailitems.
I think sysmail_mailitems is the table which you need.

How do I copy the data from one table to another identical table using SQL Server r2008 and C#?

I have both a local server and remote server that has an identically structured table in each. In the local server I have a database table which is inserted, updated regularly. There is no primary key in the table
Once a week I want to copy the data from the local table to the identical table in the remote server.
Please help me to find the solution.
I believe what you are trying to do is a Mirror database, updated weekly, if that is the case:
Using Database Mirroring is a best practice instead of manually doing this yourself, I suggest you read about Mirroring here:
Database Mirroring
And afterwards follow this guide:
Setting Up Database Mirroring
your local server should be the principal and your remote will be the mirror
Edit:
Just to be clear, I highly recommend this approach, it will give you benefits such as automatic failover (when your local server crashes it will use the remote one) , you can read all about the benefits in the links above so I won't carry on and on about it, just emphasize that is recommended.
Since these are both existing tables you would do something to the extend of the following:
INSERT INTO [DATABASE IP].databasename.schemaname.tablename
(
column1
,column2
,column3
,column4
,column5
,column6
)
select
column1
,column2
,column3
,column4
,column5
,column6
from tablename
where --some condition here, maybe on date?
For this to work you will need to make sure that you have the same login name in both databases both local and remote as well as the same password in both.
Once Try this..
INSERT INTO DestinationTable (Column1,Column2,Column3)
SELECT Column1,Column2,Column3 FROM SourceTable

Pass-through queries and linked table queries using different connections

Follow-on to an earlier question: Force SET IDENTITY_INSERT to take effect faster from MS Access
I'm in the process of upsizing from an MS Access backend to a SQL Server backend. Many of the tables have autonumber primary keys. I'm trying to populate them as follows (pseudocode):
ExecutePassThru "SET IDENTITY_INSERT dbo.Accounts ON"
db.Execute "INSERT INTO sql_Accounts SELECT * FROM mdb_Accounts"
ExecutePassThru "SET IDENTITY_INSERT dbo.Accounts OFF"
In the above code, sql_Accounts is a linked table connected to the Accounts table in SQL Server and mdb_Accounts is a linked table connected to the Accounts table in the mdb. This fails with the error,
Cannot insert explicit value for identity column in table 'Accounts' when IDENTITY_INSERT is set to OFF.
I fired up SQL Server Profiler to try to figure out the problem and the issue is that each line of code in my sample may or may not use a different Server Process ID (SPID). In other words, they are using different connections to the backend.
Is there some way to ensure they all use the same connection?
There may be a more elegant solution, however this a one time conversion and it's not worth too deep of dive trying to do complex things with connection reuse.
Create a staging table on the SQL Server that does not contain an identity but is otherwise of the same schema.
Load your data to that table
Do your identity insert entirely on the SQL Server side.

Resources