Solved

copy SQL query from ACCESS to SQL

Posted on 1998-07-09
11
170 Views
Last Modified: 2010-03-19
I have some queries in Access and I am trying to use these as stored procedures in SQL, is there a way like copy/paste that I can use to copy these queries to the stored procedure windows in SQL Enterprise Manager ( then make some changes to them if needed) instead of retyping the whole thing again?
0
Comment
Question by:khal
  • 6
  • 4
11 Comments
 
LVL 2

Expert Comment

by:odessa
ID: 1091691
Yes you can do this, only copy the SQL querys encapsulate then in stored procedures (make changes if needed) and go ahead
0
 

Author Comment

by:khal
ID: 1091692
the problem is how to copy them, because it looks like there is no paste option in the Enterprise Manager stored procedure window? is there another way, please send it in details.
0
 
LVL 4

Accepted Solution

by:
tomook earned 30 total points
ID: 1091693
Use Control+C to copy and Control+V to paste.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:khal
ID: 1091694
the problem is how to copy them, because it looks like there is no paste option in the Enterprise Manager stored procedure window? is there another way, please send it in details.
0
 

Author Comment

by:khal
ID: 1091695
I can't see your answer tomook?
0
 
LVL 4

Expert Comment

by:tomook
ID: 1091696
Open the Access queries in SQL view, highlight the SQL, hit Control+C(copy). Open a new stored procedure, then use Control+V to paste the SQL. Name the stored procedure and clean up the SQL (SQL Server does not like semicolons, for example).
0
 
LVL 4

Expert Comment

by:tomook
ID: 1091697
By the way, if you need help cleaning up the SQL (INNER JOIN, ...), just ask.
0
 

Author Comment

by:khal
ID: 1091698
by the way, is it possible to have a stored procedure reads from another stored procedure??. I have a stored procedure that should  read from another stored procedure, but whenever I try to save the new stored procedure , an error comes up saying there is no object with the name of the old stored procedure that it is reading from??
0
 

Author Comment

by:khal
ID: 1091699
when I save the first stored procedure as a view, then the new stored procedure can read it with no problem???
0
 
LVL 4

Expert Comment

by:tomook
ID: 1091700
First, you should use views whenever you can. Second, when you are editing a stored procedure in Enterprise Manager, the first 5 or 6 lines are to delete the stored procedure. If you use the route of editing an existing stored procedure to create a new one, watch out for this! If these are not the problems, post your Transact SQL and I will see what I can do. Might want to make it a new question so the other experts can get in on it without spending points.
0
 

Author Comment

by:khal
ID: 1091701
this is the old stored procedure(qtmpRainFall) that is called by the second one
two parameters are sent to it

if exists (select * from sysobjects where id = object_id('dbo.qtmpRainFall') and sysstat & 0xf = 4)
      drop procedure dbo.qtmpRainFall
GO

CREATE PROCEDURE qtmpRainFall @MyBeginDate datetime, @MyEndDate datetime AS
select @MyEndDate=dateadd(day,1,@MyEndDate)
SELECT tblFieldMeasurement.CollectionDate, Avg(tblFieldReading.ReadingValue) AS Rainfall,

FROM tblFieldMeasurement INNER JOIN (tblFieldReading INNER JOIN tlkpEMParameter ON
tblFieldReading.EMParameterID = tlkpEMParameter.EMParameterID) ON
tblFieldMeasurement.MeasurementID = tblFieldReading.MeasurementID
GROUP BY tblFieldMeasurement.CollectionDate, tlkpEMParameter.EMParameterName
HAVING tblFieldMeasurement.CollectionDate Between @myBeginDate And
 @myEndDate AND tlkpEMParameter.EMParameterName="Rainfall"

GO

this is the new stored procedure that calls the previous one

CREATE PROCEDURE qsnpRainFall @MyBeginDate datetime, @MyEndDate datetime AS
SELECT convert(char,collectiondate,1) AS JoinDate, qtmpRainfall.Rainfall,
Rainfall *0.4 AS MMGalRain
FROM qtmpRainfall

actually I added the parameters here (@MyEndDate, @MyBeginDate) because I thought these might solve the problem but it didn't (the new stored procedure reads some information from the old stored procedure results without sending any arguments, but since the old stored procedure needs argument anyway, I thought I might send them through the new one)


0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Slow Connectivity over ODBC 8 35
T-SQL: Episode III - Revenge of The Dude 24 53
VBScript Write Column Headers 3 37
Tsql query 6 22
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

773 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