Access Front End to SQL Server (1 Viewer)

ECEK

Registered User.
Local time
Today, 03:59
Joined
Dec 19, 2012
Messages
717
When querying the SQL data: my colleagues use the (no lock) method when extracting from the live data.

I want to create an Access database that in linked to the SQL database and uses an append query from the SQL Server to a local table. I can then create my front ends.


My question is : If I set up my Access database in this way do I need to be aware of any locking issues as the SQL Server data is live data.

Could I get some advice on this please?
Thanks people.
 

Ranman256

Well-known member
Local time
Yesterday, 22:59
Joined
Apr 9, 2015
Messages
4,339
I don't use it. Running an append qry should not interfere w anyone.
 

Minty

AWF VIP
Local time
Today, 03:59
Joined
Jul 26, 2013
Messages
10,368
The lock properties set in access queries have no effect on how SQL Server locks records in tables. SQL server handles all the record locking at it's end.

The only thing you need to be aware of is if you use VBA to open recordsets or update records - You then need to enable update execution with the correct options such as Currentdb.Execute MySqlStatement , dbSeeChanges
 

ECEK

Registered User.
Local time
Today, 03:59
Joined
Dec 19, 2012
Messages
717
The only thing that will happen is a macro to run the Append Query. That's the only interaction with the data. As soon as the data has been imported into my table I can create my front ends (queries etc) off it.

My only other question would be regarding the linked connection to the SQL server data.

Does the link remain active when the Access database is open or only when it is being queried?
 

Minty

AWF VIP
Local time
Today, 03:59
Joined
Jul 26, 2013
Messages
10,368
So you are copying/appending the data from SQL server to the local FE?
Do you have to do that or can't you just query the linked SQL table ? It would be more efficient unless you have LAN / WAN issues or can't maintain the connection.

I believe that the ODBC connection is dropped after 60 seconds of inactivity and then reconnected on demand - but don't quote me on that.
 

ECEK

Registered User.
Local time
Today, 03:59
Joined
Dec 19, 2012
Messages
717
I will have a linked table (SQL Server)
I will have an append query to pull in the data that I want
The table that it pulls it into will be the basis of my reporting. It's a snapshot report so I only need to do this twice a day and don't want to be reporting on live data, just live data that I have imported. (If that makes sense!!)

My concern is that however brief my append query is: It won't lock anybody out on the SQL Server.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:59
Joined
Jan 23, 2006
Messages
15,379
If your SQL server is an online transaction database, then you can not guarantee that any reports you build based on your snapshot will match any other reporting.

We had the same logical issue years ago. We built PIT (point in time ) databases for analysis and reporting. These were extracted from the production database at MonthEnd, QuarterEnd Year End. Having consistent data was critical to several people and areas doing analysis and forecasting.

Perhaps your environment and conditions are different.

Good luck.
 
Last edited:

Minty

AWF VIP
Local time
Today, 03:59
Joined
Jul 26, 2013
Messages
10,368
To answer your question - no - nobody should be locked out, as you are only reading from the source table, all the writing is done locally to a local table.
 

SQL_Hell

SQL Server DBA
Local time
Today, 03:59
Joined
Dec 4, 2003
Messages
1,360
I don't understand why you want to pull all the data into access all the time?

Won't that copy of the data become out of date quickly, requiring a new data refresh to be issued every time something changes?

Can't you just query the data directly on the sql server to run reports and forms? otherwise you are defeating the object of having a SQL server in the first place
 
Last edited:

ECEK

Registered User.
Local time
Today, 03:59
Joined
Dec 19, 2012
Messages
717
At present I am unable to manipulate SQL Server in the same way that I can build front ends forms, reporting and queries in Access. It is a means to an end at the moment. I do intend to progress but I want to build the model first.

How would you suggest I progress within SQL?
 

Minty

AWF VIP
Local time
Today, 03:59
Joined
Jul 26, 2013
Messages
10,368
You can treat any table in SQL as if it's a local access table, just link to it. You can do anything to the data you want in almost exactly the same way.

The only differences are subtle changes in data types. But a bit of pre reading will get you past that without much drama, and if I'm reading your post correctly the data is already in SQL Server so those changes are already present.
 
  • Like
Reactions: Rx_

SQL_Hell

SQL Server DBA
Local time
Today, 03:59
Joined
Dec 4, 2003
Messages
1,360
You can treat any table in SQL as if it's a local access table, just link to it. You can do anything to the data you want in almost exactly the same way.

The only differences are subtle changes in data types. But a bit of pre reading will get you past that without much drama, and if I'm reading your post correctly the data is already in SQL Server so those changes are already present.

This is what I meant, I didn't mean do away with MS Access altogether, I meant get the data from SQL server by querying linked tables in MS Access rather than issue a data load into access every time.
 
  • Like
Reactions: Rx_

Rx_

Nothing In Moderation
Local time
Yesterday, 20:59
Joined
Oct 22, 2009
Messages
2,803
Good questions and good advice. There are several "it depends" as might be expected.
Let me add one more level.
Linked Tables via ODBC is much like using an Access table (plus the data type differences) described above.
Even in Access (or SQL Linked Tables) my preference is not to link a form directly to a Table. Link the form to a Query.
Access since at least 2010 (maybe 2007) actually has some great internal features at the form level to interact with SQL Server. To prepare for Azure, they added features to prevent the worries of locking (in the average use)

When using a Query with a parameter(s) (Filter), ODBC actually communicates with SQL and creates the equal of a Stored Procedure.

But, let this be a warning. In the Access Query, avoid non SQL functions. For example an Access Query can use the immediate If statement. Or, Access can use public VBA Functions (UDF) in the Query. These Access only queries should be avoided in the Form's query def. Stick to standard SQL standard queries.

Using a SQL statement query, SQL will actually evaluate the request and utilize the index and other execution plans.

You indicated that you don't currently have access to SQL Server outside Linked Tables.
Many of us believe that a Table in SQL Server that becomes a Query (View) is what Access should be linked to. A View in SQL Server can be one table with added security and other administration context.

I have one form that uses a query that links a dozen tables.
This query was moved to SQL Server to create a View. My Access application used the Linked Table to this View. In a prototype stage, I probably build the query on my Access side. Later, it moves to SQL Server as a View.

Generally, you appear to be on the right track. You are asking good questions. And, you have the added benefit of receiving some excellent answers from high quality people.
Your process will be fine. And, then it can be improved as it progresses.
 

SQL_Hell

SQL Server DBA
Local time
Today, 03:59
Joined
Dec 4, 2003
Messages
1,360
Excellent post rx_.

I have to say you are really good at adding the extra information required to make the above advice more understandable.

To the OP, I hope that helps explain things better, my thinking was that if you go down this road now (copying data into access rather than query directly), then it really could bite you in ass later down the road.

That one request to copy data into access could easily morph into more than one time a day, then someone will want a new report requiring a new set of tables and before you know it, you'll be copying 10 tables every hour and then you really will be causing performance problems on the sql server.

As a side note, be wary of "no lock" it just doesn't issue a shared lock, which doesn't necessarily mean no lock will be issued and there are some scary consequences such as dirty reads. Here is a good article about no lock.

http://blogs.sqlsentry.com/aaronbertrand/bad-habits-nolock-everywhere/
 

ECEK

Registered User.
Local time
Today, 03:59
Joined
Dec 19, 2012
Messages
717
So as a close: Advice

I am now able to create a fantastic array of "front ends" using Access built on a SQL back end.

My abilities (now that I've imported the data locally) are magical !! Whoopie I can do all my stuff.

How the F do I replicate this within SQL? Is it within SSRS?
Your advice is really welcome !!
 

Rx_

Nothing In Moderation
Local time
Yesterday, 20:59
Joined
Oct 22, 2009
Messages
2,803
What exactly are you trying to replicate?
I want to make sure exactly what you want before I go of on my missive. LOL
 

Minty

AWF VIP
Local time
Today, 03:59
Joined
Jul 26, 2013
Messages
10,368
So as a close: Advice

I am now able to create a fantastic array of "front ends" using Access built on a SQL back end.

My abilities (now that I've imported the data locally) are magical !! Whoopie I can do all my stuff.

How the F do I replicate this within SQL? Is it within SSRS?
Your advice is really welcome !!

I think you may have missed our collective points.

Use your wonderful Access fronts ends Directly on your SQL tables. You don't need to import the data - simply link the SQL tables IN access instead of importing the data.
 

SQL_Hell

SQL Server DBA
Local time
Today, 03:59
Joined
Dec 4, 2003
Messages
1,360
Have a look at the "linked table manager" in Access, here you can create links / shortcuts to the tables in SQL server. You will need to enter server name, database name, login details.

Provided you're allowed to do this of course.
 

kevlray

Registered User.
Local time
Yesterday, 19:59
Joined
Apr 5, 2010
Messages
1,046
Another handy tool to avoid having to use an local ODBC connection is the MS Server Migration Assistant. It is a useful tool to move Access tables to an MS-SQL instance and do the linking. The linking does not require a local ODBC connection to be set up.
 

SQL_Hell

SQL Server DBA
Local time
Today, 03:59
Joined
Dec 4, 2003
Messages
1,360
The OP already has tables full of data in SQL server, so I don't think using the migration assistant is applicable here. It would overwrite the live tables.
 

Users who are viewing this thread

Top Bottom