0

Why m i getting error incorrect syntax near the keyword IN in the following query?

select * into persons_backup IN 'HRMS.mdb' from persons

Thank you

0

2 Answers 2

3

Assuming SQL Server (based on your previous question) you would need

select * 
into persons_backup 
from HRMS.mdb.persons

or

select * 
into HRMS.mdb.persons_backup 
from persons

dependant upon what you are trying to do exactly. See SELECT ... INTO syntax here

Sign up to request clarification or add additional context in comments.

10 Comments

I tried ur second option but it says "The specified schema name "mdb" either does not exist or you do not have permission to use it." Please clarify how can i get rid of that. Secondly, whats wrong with my query(specified in the ques)? The syntac i hav used is the one specied in w3schools.
I had to guess what you are trying to do as your question just provides invalid syntax with no explanatory text. HRMS.mdb.persons is ih the format databasename.schemaname.tablename If you don't have a schema called mdb then what are you trying to do exactly? To SELECT ... INTO a table in your default schema just use select * into persons_backup from persons
i want to create backup of persons table in another database called "HRMS". This database already exists.
This is another SQL Server Datbase? If so why does your query have .mdb If there is no such schema? You need to create this schema or use a different existing one. e.g. select * into HRMS.dbo.persons_backup from persons
|
1

Assuming you want to add all rows from persons into another table persons_backup:

Insert into persons_backup select * from persons;

Depending on the RDBMS you use, you might have to put () around the select.

1 Comment

For using this query i will hav to create the "persons_backup" table first. I am trying to use select into for creating backup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.