Board index » delphi » Create of Tables SQLServer -> Access.mdb

Create of Tables SQLServer -> Access.mdb

Hi
I would like to create a copy of a table in SQL2000 in a Access DB in code
from Delphi 5.0 , basicaly just the table structure , in other words a empty
table, and populate it later with some data?

Can anybody  hlp me please?

 

Re:Create of Tables SQLServer -> Access.mdb


Quote
>I would like to create a copy of a table in SQL2000 in a Access DB in code
>from Delphi 5.0 , basicaly just the table structure , in other words a empty
>table, and populate it later with some data?

>Can anybody  hlp me please?

You can do a query

Select * Into   NewTable
From OldTable
Where Somefield = someCondition

if the Where clause doesn't select any records you end up with an empty table of
the same structure as the table in the from
This doesn't get you any indexes you would have to add any indexes you need with
SQL alter Table code.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Create of Tables SQLServer -> Access.mdb


"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:2oi9ruso0ilptivarn26mesd4ic1k54pn4@4ax.com...

Quote

> >I would like to create a copy of a table in SQL2000 in a Access DB in
code
> >from Delphi 5.0 , basicaly just the table structure , in other words a
empty
> >table, and populate it later with some data?

> >Can anybody  hlp me please?

> You can do a query

> Select * Into   NewTable
> From OldTable
> Where Somefield = someCondition

> if the Where clause doesn't select any records you end up with an empty
table of
> the same structure as the table in the from
> This doesn't get you any indexes you would have to add any indexes you
need with
> SQL alter Table code.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Thanks Brain
But how to do when the original table is in SQL2000 DB and the copy must be
in Access DB, surely the "Select * from oldtable into newtable" would create
the new table in the same DB where the statemant was executed?

Re:Create of Tables SQLServer -> Access.mdb


Quote
>But how to do when the original table is in SQL2000 DB and the copy must be
>in Access DB, surely the "Select * from oldtable into newtable" would create
>the new table in the same DB where the statemant was executed?

Sorry I overlooked that you had two different databaes

SQL server has two ways to do this.
First you can create a linked server to any ole db Database

Second you can use syntax like this

Select * into NewEmp
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'c:\apps\northwind.mdb';'admin';'password', Employees)

Quote

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads