Solved

Help creating my first SQL ViewSQL

Posted on 2013-01-30
6
428 Views
Last Modified: 2013-01-31
This will be my first attempt at setting up an SQL view and I am hoping that someone out there can answer a couple quick questions for me. I need to select data from a SQL table located off-site and bring that data into Microsoft access locally. Will the SQL View code reside offsite where the SQL database resides or is it on my side where my computer and Microsoft access resides?

Our J.D. Edwards ERP system is managed by an off-site company, Titan Technologies Inc. The data that I need will come from the SAL server located at Titan across our data line to our local office here in Newton North Carolina. Could someone give me a very quick blow-by-blow education or point me to a place where I can get the information that I require.

Below, is what I believed to be the correct code for my first SQL View.

CREATE VIEW F4111 AS
SELECT PRODDTA.F4111.ILNLIN, PRODDTA.F4111.ILITM, PRODDTA.F4111.ILLITM, PRODDTA.F4111.ILAITM, PRODDTA.F4111.ILLOCN, PRODDTA.F4111.ILTRNO, PRODDTA.F4111.ILFRTO, PRODDTA.F4111.ILKIT, PRODDTA.F4111.ILMMCU, PRODDTA.F4111.ILKCO, PRODDTA.F4111.ILDOC, PRODDTA.F4111.ILDCT, PRODDTA.F4111.ILJELN, PRODDTA.F4111.ILICU, PRODDTA.F4111.ILGLPT, PRODDTA.F4111.ILDCTO, PRODDTA.F4111.ILDOCO, PRODDTA.F4111.ILKCOO, PRODDTA.F4111.ILLNID, PRODDTA.F4111.ILIPCD, PRODDTA.F4111.ILTRDJ, PRODDTA.F4111.ILTRUM, PRODDTA.F4111.ILAN8, PRODDTA.F4111.ILTREX, PRODDTA.F4111.ILTREF, PRODDTA.F4111.ILTRQT, PRODDTA.F4111.ILUNCS, PRODDTA.F4111.ILUKID, PRODDTA.F4111.ILCRDJ, PRODDTA.F4111.ILAID, PRODDTA.F4111.ILASID, PRODDTA.F4111.ILMCUZ, PRODDTA.F4111.ILOBJ, PRODDTA.F4111.ILSBL, PRODDTA.F4111.ILSUB, PRODDTA.F4111.ILUOM2, PRODDTA.F4111.ILCMOO, PRODDTA.F4111.ILRE, PRODDTA.F4111.ILSBLT, PRODDTA.F4111.ILSQOR, PRODDTA.F4111.ILVPEJ, PRODDTA.F4111.ILHDGJ, PRODDTA.F4111.ILSHAN, PRODDTA.F4111.ILOPSQ, PRODDTA.F4111.ILRFLN, PRODDTA.F4111.ILTGN, PRODDTA.F4111.ILLOTC, PRODDTA.F4111.ILSVDT, PRODDTA.F4111.ILLRCD, PRODDTA.F4111.ILRLOT, PRODDTA.F4111.ILLPNU
FROM PRODDTA.F4111
WHERE (((PRODDTA.F4111.ILMCU) Like '       31101' Or (PRODDTA.F4111.ILMCU) Like '       31110' Or (PRODDTA.F4111.ILMCU) Like '       31120' Or (PRODDTA.F4111.ILMCU) Like '       31130' Or (PRODDTA.F4111.ILMCU) Like '       31140' Or (PRODDTA.F4111.ILMCU) Like '       31150'));
Regards,

Tw
0
Comment
Question by:Tom Winslow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 85
ID: 38837283
Views are stored in the server database. Views are handled just like Tables, in regard to linking, opening via recordsets, etc.

What is it you want to do after building and saving the View on the server? If your goal is to store the data locally, then the best way to do that is to link to the table or view, and then use something like a SELECT INTO statement to save the data into a local table.

To do THAT,, you'd need to build and link the view, and then do this AFTER you've linked the view:

Currentdb.Execute "SELECT * INTO MyLocalTable FROM MyLinkedView."

Note that "MyLocalTable" cannot already exist, so you might need to use a DROP statement first:

Currentdb.Execute "DROP MyLocalTable"
0
 

Author Comment

by:Tom Winslow
ID: 38837453
I need to get the data local into an MS Access database. Should I use a PassThru Query or can I link directly to the View in the same manner that I currently link to the tables?
0
 
LVL 85
ID: 38837479
You could use a PassThrough, but in  general if you need to localize the data a simple linked table with the SELECT or INSERT query works best.
0
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 

Author Comment

by:Tom Winslow
ID: 38839728
I am wanting to use Views because:

1. The tables are too large to access all of the needed data directly with an ODBC connection to the table. The view employs filtering for the needed data.
2. Security. The Associate that will be using the data cannot have access to the entire table(s).

Not being familiar with VIEWS, I am assuming that security can be applied to the VIEW.

tw
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 38839831
You can treat an SQL View the same as you do a table, so yes you could apply security to a View independent of it's root tables.

However, you're talking apples and oranges when you refer to a PassThrough vs a View.

A PassThrough Query in Access is simply a query that is "passed through" Access to the source database, as defined in the Connect property of that Query. Your PassThrough query could point to a View, or a Table.

A linked View is no different than a linked Table, as far as Access is concerned.

So you could have either one - a linked View, or a PassThrough query that is build using a View on the server.
0
 

Author Closing Comment

by:Tom Winslow
ID: 38839841
Great! All my questions answered. I am off and running.

Thanks.

tw
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question