Solved

Access ADP Project, SQL Table Creation Statements

Posted on 2004-10-17
12
488 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
  • 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now