Create a Make Table from Ms Access Into Sql-Server - ms-access

I work at a firm that is starting to utilize a hybrid data management system (Ms Access front end, Sql-Server backend). We have many many many people who are proficient in Access (as access suffices about 90% of our needs) but we starting to run into size issues. As we make the migration, I'd love to use as little T-SQL Code as possible to allow people to continue with their current workflows. For the few projects that have Sql-Server, I've used SSMA to push tables from access to SQL Server but I am looking for a more efficient way to do this. Ultimately I'd love to copy the efficacy of an MS Access make table query. I'd rather not use the time consuming method of:
Create Table Location_Sql_Test (
Column 1 varchar(50)
Column 2 varchar(50)
etc.
etc.)
Is there a way to do something like the below? Do note that Location_Sql_Test doesn't exist yet in my Sql-Server database.
SELECT *
INTO
[ODBC;DRIVER=SQL Server;SERVER="myserver";DATABASE="myproject";Trusted_Connection=yes].Location_SQL_TEST
FROM Location_SQL;
Literally, can I create a table in Sql-Server from MS Access without needing to open SSMA or SSMS?
Thanks!

You can do this like this:
SELECT * INTO
[ODBC;DRIVER=SQL
Server;SERVER="myserver";DATABASE="myproject";
Trusted_Connection=yes].Location_SQL_TEST
FROM Location_SQL;
So:
SELECT * INTO
[ODBC;DRIVER=SQL
Server;SERVER="myserver";DATABASE="myproject";
Trusted_Connection=yes].MySQLServerNewTableName
FROM MyLocalAccessTable;

Related

Insert static data in database in SSDT

I want to pre populate my data base table with some defined data in SSDT. Such that insertion data take place only once. I am using SQL 2005 ?? How can I do this ??In SQL 2008 there is MERGE but I am not finding solution in 2005!!!
I was all excited until I saw you used SQL 2005 ;), poor you I feel your pain as up until recently I was working with a SQL 2005 db.
You will need to do something like:
"if not exists (select * from table where col = blah
Insert xxx into table
"
If you have lots of rows then you could look at doing something like checking one of the rows and doing a bulk insert or openrowset from a cav file -or- use redgate data compare to manage it for you.
Ed
If it's pre-defined, you might be able to get away with saving that out and inserting using BCP or something similar. You can also write the script and call it as part of some sort of "IF NEW" check. However, your best bet for an ongoing script would be to insert into a temp table, then do some sort of EXCEPT or LEFT JOIN to figure out what doesn't exist and update or insert as appropriate.
There's not a really clean way to do it, but it is doable. My concern would be that you may want to consider a separate "New" script and tell people to create the database, then run that script afterwards if they re-created the DB. This would keep the size of your main release scripts a bit more manageable.

Create single SQL Server 2008 application database from multiple part application databases

I have a situation where I have an application that uses multiple SQL Server 2008 databases (all with different schemas - split by application function).
I now want to combine these schemas and data into a single overall application database (SQL Server 2008). I've searched for help on how to do this, but all the solutions I've seen have covered merging data from databases with identical schemas. In this case, there is no commonality in the schemas of the separate databases - all the tables are unique. For this, I just want to combine all the tables and data into a single database, and I'm really looking for a tool that will help me do it simply and easily.
Can anyone give some guidance on how this could best be achieved?
I guess you can create a script something like this ... in your Source database execute the following statement in with Results to Text selected
SELECT N'SELECT * INTO [dbo].['+ TABLE_NAME + N'] FROM [ServerName].[Database].['
+ TABLE_SCHEMA + N'].[' + TABLE_NAME + N']; ' + CHAR(10) + N'GO'
FROM information_schema.tables
WHERE TABLE_TYPE = 'BASE TABLE'
And it will generate the script as follows. all you need to do is copy it from results pane and paste it in query window , Target database context and job is done ....
SELECT * INTO [dbo].[TestTable] FROM [ServerName].[Database].[dbo].[TestTable];
GO
SELECT * INTO [dbo].[TableOne] FROM [ServerName].[Database].[Account].[TableOne];
GO
SELECT * INTO [dbo].[TableTwo] FROM [ServerName].[Database].[Account].[TableTwo];
GO
SELECT * INTO [dbo].[TableTHREE] FROM [ServerName].[Database].[Account].[TableTHREE];
GO
SELECT * INTO [dbo].[TableTHREE] FROM [ServerName].[Database].[HumanResource].[TableTHREE];
GO
SELECT * INTO [dbo].[TableOne] FROM [ServerName].[Database].[HumanResource].[TableOne];
GO
SELECT * INTO [dbo].[TableTwo] FROM [ServerName].[Database].[HumanResource].[TableTwo];
GO
Issues with this Script
1) Since you want to get tables from multiple schemas thrown into one
schema in the destination database there can be some duplicate Table
Name as I have shown in my above example.
2) Tables that has columns that references column in other
tables must me created after the table containing referecing column is
created.
I suppose you would not find such tool. You require custom functionality which is not very common. Therefore, I suppose nobody would make a tool for it. Your scenario is not very clear. I would see three ways of moving.
If this merge is going to happen once, then it is quite easy. You could export the tables in the form of a CREATE SQL statement, including data. You could use this tutorial to do it in SQL server. You should do this for every table and then run these scripts to create the tables into the new schema.
If you want to merge the databases contents in the target database in a regular basis, you have to create an SQL Server Job. This would have to execute the custom scripts which would pull data from the source databases and push them to the target database.
If you want to concatenate a number of smaller databases in a big data warehouse, then you are looking for the Business Intelligence Development Studio. You could use it to create an OLAP cube, concatenating data from the smaller databases in the big data warehouse.
Hope I helped!

Best way to synchronise data: MySQL -> SQL Server

I have a fairly straight way to copy selective data using SQL like so:
# Courses
DROP TABLE db_node.courses;
CREATE TABLE db_node.courses LIKE db_prod.course_sis;
INSERT INTO db_node.courses SELECT
*
FROM
db_prod.course_sis
WHERE
db_prod.course_sis.enabled = 1
AND db_prod.course_sis.hidden <> 1;
This is easy when I am on the same server with the same db, however I want to run this SQL to get put the final data on the SQL Server.
This isn't just a once off thing, it would need to be handled every hour or so. I am unable to change db's, one will always be MySQL and SQL Server because the data is used in a sharepoint app.
Thanks
There are several third-party tools to make this transition easier.
Check out SSMA here and here.
I'd also look at SQL Studio scheduled tasks to automate the process.

MSACCESS 2002 Linked Table Performance Really Slow

Am trying to import some selective data and create a table in MS Access db 2002 from a linked table. For some odd reason the performance became really bad all of a sudden when importing the data.
I tried googleing and tried various methods like reparing/compacting the db, Changing the SubDataSheet Name to [None] from [Auto] but either one worked.
Can any one please give me some examples to increase the performance of linked tables.
Thank you.
Rather than selecting information from a linked table and trying to make a local table, when using a database server like MS MSQL, you would be better to create a "Pass Through Query" to do the select work on the server side, and then carry out a simple select * on this pass through to get your data in to a local table. This will give the best results if your first select statement is complex and takes a while for Access to run on a linked table, if that is not the issue then you will need to look at your network speed which connects you to your MS SQL server.

How to tell if someone is looking at one of the records on your database?

I want to add some fake records/rows for in the table for MS SQL 2008 Standard Edition database and use these records to monitor my database.
The purpose for this is to monitor hackers. It is possible to create a trigger to do this. It seemed like the DDL Triggers can not do this tasks.
If you can't control access to your database via stored procedures (where you could add your own logging), you will need to use auditing or server-side trace for this. There is no such thing as a select trigger and there are no DMVs that will tell you which rows were looked at via any select action.