Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
can you help me convert this SQL query to access query,
i dont know if this is working in one query design in access

SQL
DELETE FROM tblReportTempData

INSERT INTO tblReportTempData
           (fxQuestionnaire,fxNewID)
SELECT  fxQuestionnaire,newid()
            FROM        dbo.tblTestPaper
WHERE     (fxTestCode = @fxTestCode)
            order by  newid()
SELECT * FROM       tblReportTempData   order by fxNewID
Posted
Comments
Maciej Los 28-Nov-13 4:15am    
Do you have any reason to convert it?
There is not enough information to reply. Please, be more specific and provide more details about issue.
What have you done so far? Where are you stuck? Do you have any errors?
U-mar 28-Nov-13 4:17am    
its my job to do it. is this possible to insert,delete,update in one access query design?
Maciej Los 28-Nov-13 4:21am    
Please, read my comment to the end and answer for every single question, which means: provide more details about issue. At this moment the question is unanswerable.
U-mar 28-Nov-13 11:18am    
this is a sql query . i want to do this in access query procedure . i have error like "syntax error in FROM clause".

As far as I know, this is not possible to execute multiple statements in one single query in Access.
 
Share this answer
 
There is no equivalent NEWID() function in MS Access. If you want to create global unique identifier, you need to create VBA function[^].

Another difference: How to MS Access proceed with parameters[^]. Parameters are used to make a query ask user for input[^]

Finally, query should looks like:
SQL
PARAMETERS fxTestCode INT

DELETE FROM tblReportTempData;

INSERT INTO tblReportTempData (fxQuestionnaire,fxNewID)
SELECT  fxQuestionnaire, GUID() AS fxNewID
FROM  tblTestPaper
WHERE fxTestCode = [fxTestCode]
ORDER BY GUID();

SELECT *
FROM tblReportTempData
ORDER BY fxNewID;


Another
 
Share this answer
 
Comments
U-mar 28-Nov-13 12:35pm    
so it means that i cant do INSERT,UPDATE,DELETE in one query design in access?
Maciej Los 28-Nov-13 13:25pm    
Yes, you can't. Please, see this: Type of queries - MS Access[^]
U can use stored procedure or view for this....
 
Share this answer
 
Comments
phil.o 28-Nov-13 5:06am    
Sorry, but wrong: there is no stored procedure in Access
Maciej Los 28-Nov-13 11:23am    
Agree!
U-mar 28-Nov-13 10:09am    
i need to do this in access query procedure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900