开发者

Import multiple queries written in SQL into access

I've got to write 50 relatively simple queries, that all use the same basic form, but each successive query depends on the one before it to run.

I can quick and easily write the queries in SQL in an text editor e.g. word, but I dont know how to import the text back into access. Nor do I know how to specify the name of the query in the SQL code or how to specify that the end of a query has been readched.

Here is a sample of 4 queries. Here, the 1st line is the name of the Query and the two consecutive hard return represents the end of eqch query.

‘Ring2Q1 SELECT RINGS.Parent, RINGS_1.Child, 2 AS Ring FROM RINGS INNER JOIN RINGS AS RINGS_1 ON RINGS.Child = RINGS_1.Parent;

‘Ring2Q2 SELECT Ring2Q1.Parent, Ring2Q1.Child, Max(Ring2Q1.Ring) AS Ring FROM Ring2Q1 GROUP BY Ring2Q1.Parent, Ring2Q1.Child;

‘Ring3Q1 SELECT RINGS.Parent, Ring2Q2.Child, 3 AS Ring FROM RINGS INNER J开发者_JS百科OIN Ring2Q2 ON RINGS.Child = Ring2Q2.Parent;

‘Ring3Q2 SELECT Ring3Q1.Parent, Ring3Q1.Child, Max(Ring3Q1.Ring) AS Ring FROM Ring3Q1 GROUP BY Ring3Q1.Parent, Ring3Q1.Child;


Go into Access. Create a new query. Select SQL View. You can copy and paste the text of the query in here. Save it as the name you need for the next query. Repeat. You will obviously need a starting table that the first query calls. I would look at why you need a cascading set of 50 queries, on any sizeable amount of data this is going to take a long time to run.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜