Solved

Access ADP Project, SQL Table Creation Statements

Posted on 2004-10-17
12
518 Views
Last Modified: 2006-11-17
I have a Microsoft Access(.adp) project with 16 tables in it. I'm running MSDE so that tables are in SQL server. I need to output the create statements for the tables and the attributes of each table, plus the primary key/foreign key relations how do I do it??

I need statements like this:
Create table firstcare_centers (
center_id            decimal(4) not null,
center_name      varchar(15),
pharmacy_id      decimal(4) not null,
pharmacy_name      varchar(50),
address            varchar(60),
city                  varchar(15),
state            varchar(4),
zip_code            varchar(10),
phone_number      varchar(13),
upsize_ts            timestamp(2),
Primary Key(center_id));




Create table independent_contractors (
contractor_id      decimal(4) not null,
first_name      varchar(10) not null,
last_name            varchar(20) not null,
pager            decimal(13) not null,
speciality      varchar(50) not null,
center_id            decimal(4),
Primary Key(contractor_id),

Constraint fk_firstcare_centers_independent_contractors foreign key(center_id)
References firstcare_centers ON DELETE cascade);




Create table center_physician_schedule
Contractor_schedule_id      decimal(4),
Date                              date,
Start_time                  timestamp(2),
End_time                        timestamp(2),
Center_id                        decimal(4),
Contractor_id                  decimal(4),
Primary key(contractory_schedule_id),

Constraint fk_center_physician_schedule_independent_contractors foreign key(contractor_id)
References independent_contractors on delete cascade,

Constraint fk_center_physician_schedule_firstcare_centers foreign key(center_id)
References firstcare_centers on delete cascade);



Create General_employee_information
Employee_id                  decimal(4),
Social_security_#            varchar(50),
First_name                  varchar(10),
Middle_name                  varchar(20),
Last_name                        varchar(20),
Address                        varchar(60),
City                              varchar(15),
State                        varchar(4),
Zip_code                        varchar(10),
Phone_number                  varchar(13),
Employement_location      varchar(10),
Center_id                        decimal(4),

Constraint fk_general_employee_information_firstcare_centers foreign key(center_id)
References firstcare_centers on delete cascade);
0
Comment
Question by:Zeo
[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
  • 5
  • 3
  • 2
12 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 12336004
There are several ways you could do it.  Probably the easiest?  Create a passthru query in your ADP project and use the SP_OA stored procs in SQL Server to use the SQLDMO.  There are some examples at this site:

http://www.databasejournal.com/features/mssql/article.php/2205291
0
 

Author Comment

by:Zeo
ID: 12336299
Albert, I'm confused. I looked at that site but I'm not following SQLDMO.
0
 
LVL 34

Expert Comment

by:arbert
ID: 12337944
What aren't you following?

This line:  EXEC @hr = sp_OACreate 'SQLDMO.SQLServer', @object OUT

Creates the SQLDMO object on the server.  SQLDMO is the object model that Enterprise manager uses to do things within SQL Server.  This is also the programming extension programmers can use to access the same functionality in their programs.

Brett
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:Zeo
ID: 12339567
I'm really new to databases in general. I wrote out the create statements on my own with the primary keys, and foreign keys, but I was hoping to be able to do it directly from Access and my MSDE backend. I put the files I've created up on my website at http://www.techcacophony.net/firstcare/. I'm following an example laid out in Shcuams SQL case outlines. What I'd like to do it adapt the example from the book into MSDE.

I need really explicit steps. I have MSDE installed and I have the enterprise manager running, and I've got Visual Studio installed, so what tools do I need to use.

Many thanks and if I can get this foundation built, I'll award an additional 500 points for a grand total of 1000
0
 
LVL 34

Expert Comment

by:arbert
ID: 12339706
"Many thanks and if I can get this foundation built, I'll award an additional 500 points for a grand total of 1000 "

There is a limit to 500 points per question....

I think the link I posted above explains pretty clearly how to create scripts using the SQLDMO.  The scripts they have can be posted into Query Analyzer and ran.  It will create stored procedures on your MSDE that you can call from your ADP project...
0
 

Author Comment

by:Zeo
ID: 12339770
So just to be clear I need to be using VS.net to do this. I'm looking over at this walkthrough right now
http://www.sqljunkies.com/Tutorial/1BFBD444-DCB2-4318-A315-56BCA1D8C97D.scuk

right track, wrong track?
0
 
LVL 34

Expert Comment

by:arbert
ID: 12470184
"So just to be clear I need to be using VS.net to do this."

No, you just need to code it with something that can instantiate   an object (VBA in access will work nicely).
0
 
LVL 8

Accepted Solution

by:
SashP earned 250 total points
ID: 12576152
Zeo

I know that you haven't mentioned Enterprise Manager, however I know that you are using it.

The easiest way to create the scripts to create your database including all tables, indexes, keys, relationships etc is to use Enterprise Manager.

Right Click on your database in Enterprise Manager and select "All Tasks" -> "Generate SQL Script"

Select the required options and jobs done.

Cheers Sash
0
 
LVL 34

Assisted Solution

by:arbert
arbert earned 250 total points
ID: 12576598
"however I know that you are using it."  You have ESP?  What's my bank account balance?

EM manager will generate a "point in time" script, but if it's something you want to do continually, SQLDMO is the way to go (that's what EM uses under the covers too).
0
 
LVL 8

Expert Comment

by:SashP
ID: 12576627
Hi Brett

I helped him yesterday on another problem.  And after reading the rest of the posts here he actually mentions EM.  An yes I do have esp and your bank balance is ok, although you could be maximising your tax effective investments better.

I do not disagree with you that EM will create a point in time script. However generally this is what is required, and the question did not specify where point in time or dymanic creation is required.

Cheers Sash
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL / Table Lock? 7 39
SQL 'Fuzzy' (any part of string matches) match on passed text string in SPROC. 14 50
invoke-sqlcmd help 5 27
VM SQL server license. 1 58
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

737 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