"IN" keyword sql file path - sql-server

While moving an app from access to sql server I have come across a keyword that is causing errors. The keyword within the query is "IN". INSERT INTO Table IN 'file path of sql server database'. Does sql server allow you to insert data using the file path within the query? I have been researching this for a few days and have come up with nothing.
Thanks

The IN keyword in Microsoft Access in this syntax allows you to specify another database file where the table is. This is equivalent to being in another database in Sql Server.
It looks like you are taking multiple Access database files and importing them into multiple Sql Server databases. Let's say you have an Access database called One.MDB and it gets some data from a table in Access database Two.MDB, and you have imported into Sql Server into databases One and Two. So you need to get the data from the other database. Sql Server uses a syntax of Database.Schema.Table (the schema by default is the database owner schema, or dbo).
So this in Microsoft Access:
INSERT INTO MyTable IN 'Two.MDB' ...
translates to this in Sql Server:
INSERT INTO Two.dbo.MyTable ...
That's assuming you are still using separate databases. If you've put it all in the same database, you just need to reference the table directly:
INSERT INTO MyTable ...

Related

Automatically update SQL Server database from tables in MS Access

I'm new to SQL Server and trying to automatically update tables in SQL Server from tables in MS Access.
I have an Access database of metadata that must be kept updated for sending records to other groups. I also have a database in SQL Server which also has these same metadata tables. Currently these tables in the SQL Server database get updated manually by exporting the Access tables as Excel files, and then importing them into the SQL Server tables.
It's not the most efficient process and could lead to errors in the SQL Server database if someone forgets to check that they are using the most recent data from Access. So I would like to integrate some of the tables from Access to my database in SQL Server. Ideally I would like for the tables in my SQL Server database to be updated whenever Access is updated or at least update the tables automatically in the SQL Server database when I open it.
Would replicating the Access tables be the best? I am using SQL Server 2014 Developer so I think I have this capability. From my understanding, mirroring is for an entire database not just pieces of it. However, I do not want to be able to alter the metadata from SQL Server and have it reflected in Access. I cannot tell if reflecting the tables would do this...?
I also looked at this post about writing multiple insert statements but was confused (What is the best way to auto-generate INSERT statements for a SQL Server table?). Someone else suggested importing all the data into SQL Server and then using an ODBC driver to connect the two, but I'm also not sure how this would update the database in SQL Server anytime Access is updated.
If you have any suggestion and a link to easy to follow tutorial I would really appreciate it!
Thanks
In Access, go to 'External Data', ODBC Database, and connect to the SQL Server database directly - make sure you select 'Link to the data source by creating a linked table' on the first page of the wizard. Now, this linked table is available in Access, but is actually the SQL Server table.
Get rid of the local Access tables, using the new linked tables in their place in whatever queries, forms, reports, etc that you have in Access.
Now, any changes to the tables you see in this Access db ARE changes to the SQL Server database.

How to move data from a DB in one syabse server to another db in different sybase server?

I want to move the data from a DB to another DB where the two DB's are in two different Sybase servers.
I have tried
"INSERT INTO <target_table_name>
LOCATION target_server.target_database
SELECT FROM (source table or query);"
I have executed the above statements from the source Sybase server in RapidSQL tool but it is throwing an error "Incorrect Syntax near LOCATION".
Thanks
You could use "Component Integration Services". A table on another Sybase server is made to appear locally, as if it were a local table.
You (or the DBA) has to set up Component Integration Services and then set up the table (as a proxy table.)
If you just need the table to be copied over occasionally Meet is right - bulk copy with bcp is the thing. Look that up in the Sybase Utilities guide.

Oracle ODBC connection to SQL Server: Table Name Length Issues

I'm running into a problem when accessing a SQL Server table from an Oracle setup via ODBC.
I can access 90% of the tables absolutely fine, but there's a few tables that have a name that's longer than 30 characters. Whenever I try to interact with the table (describes, selects, etc) Oracle throws an "identifier too long" error and gives up.
Is there a way to coax Oracle into playing nice with the SQL Server tables?
Assuming that we are talking about an Oracle database that has a database link created to a SQL Server database via Heterogeneous Services, you would need to write code using the DBMS_HS_PASSTHROUGH package to interact with the tables in question. You'd also need to use this package if you have tables where there are column names that are not valid Oracle identifiers.

Join two different types of databases together

I have two databases, one MSSQL and the other in Access.
Right now, inside the access file, the mssql tables are set up as linked tables so queries can be written using tables from both databases. (e.g. "select * db1.table1 where db1.table1.somevalue not in db2.table1", or select into tables like that one)
These queries need to be moved into a VB.NET project, but still be linked to the access file.
I think what I am needing is a Database object that can have tables from 2 different connections, (ie the SqlClient and OleDb connections)
Is this possible? If so, how? Or do I need to rewrite the queries using loops or something?
What I would do is query your access database to get some result set and that pass that result set as a parameter to a stored procedure in your MS SQL database. You would just have to transform your results from access into XML to be passed as a xml variable as a parameter. And then in your stored procedure you can convert the XML to be a table variable and you can use it just like a regular table.
THere is no reason you can't create an MS Access .mdb with Links to your MS Access Database and your SQL Server database
Access Db #1 Contains Access Tables and Data.
SQL Db Contains your MS SQL Tables.
Access Db #2 contains links to the tables in Access DB #1 as well as links to the tables in your SQL Server Db. This .mdb files ALSO contains your query defs required by your vb.net project.
I'm pretty sure you can just connect to the Access database. All the internal objects--including the links to SQL Server tables--should be accessible to your vb.net project.

Easiest way to generate INSERT statements from MS Access data

I have a bunch of data in MS Access. I want to create INSERT statements from the data with the purpose of running them in SQL Server. The table structure between Access and SQL Server is the same. I don't have the option of doing an export/import because I don't have direct access to the SQL Server. It is a web host's server and they only give you a stupid control panel to run scripts. Unfortunately I can't use SQL Server Management Studio against it, or any other tools.
What is the easiest way to generate SQL Server compatible INSERT statements from MS Access data?
Install a copy of SQL Server (perhaps Express) on a machine (your dev machine, a VM, whathaveyou). Ensure your .mdb can be read by this machine.
Use SQL Server to create a Linked Server to your Access database.
DTS/SSIS tables from Access to your local SQL Server.
Export scripts + data from your local SQL Server. Right click your database, select Tasks-> Generate scripts.
choose to script data.
This will ensure that your create statements are followed by the data.
Consider using a mix of Access and Excel.
View your Access table in datasheet view.
Select all rows
Paste into Excel
Insert a new column before Column A.
Build your INSERT statement in this cell.
Insert a comma between each column (insert new column) and single quotes as needed
Insert an end parenthesis
Drag the INSERT statement, commas, and end parentheses downward, copying their values for each row in your table.
ensure you set SET IDENTITY_INSERT MyTable ON before executing that script.
It turns out I found a way that was easier than either of the suggested answers. I went to SQL Server Management Studio and right-clicked on the database, chose Import, and went through the wizard to import from an MS Access datasource. It was fairly painless and straightforward. Then I generated scripts as p. campbell suggested.

Resources