Create INSERT SQL statements

  • Thread starter Thread starter Ivan Debono
  • Start date Start date
I

Ivan Debono

Hi all,

Is there a simple way to create a query that creates Insert sql statements
based on a table and its columns and values?

Thanks,
Ivan
 
Hi,


An SQL statement can be store as a string... To read it from a saved query?
or to assign it, use the SQL property

? CurrentDb.QueryDefs("Category Sales for 1997").SQL




Hoping it may help,
Vanderghast, Access MVP
 
Ivan said:
Is there a simple way to create a query that creates Insert sql statements
based on a table and its columns and values?

Sounds like something that can be done with SQL (i.e. set-based
declarative code) but is probably better done with procedural codee.g.

SELECT 'INSERT INTO Calendar (dt) VALUES (#'
& FORMAT$(dt, 'yyyy-mm-dd') & '#);'
INTO [Text;DATABASE=C:\;].[MyScript#txt]
FROM Calendar;

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top