Re: table copy
- From: svnatraj@xxxxxxxxx
- Date: Tue, 1 Apr 2008 07:40:44 -0700 (PDT)
On Mar 29, 12:16 am, Jin <jinsooch...@xxxxxxxxx> wrote:
On Mar 27, 4:08 am, svnat...@xxxxxxxxx wrote:
hai...
Am using sql server ce2.0 in my target device.. and i would like to
copy my database table to other database... by using the following
query but it doesn't work..(following code embedded with evc++ &
wince platform)
" create table table2 like db1.table1;
"insert into table2 select * from db1.table1;
sql server ce2.0 support this query..?. it display the error message
always... plz help if anyone have an idea about how to copy the table
from one database to an other database...it would be fine...
There's no easy way to do this, however if you're willing to code,
then you could certainly achieve it. The steps involved might be:
1. Create the target database if needed.
2. Open the source database.
3. Retrieve the table schema information via the System Views (i.e.
INFORMATION_SCHEMA.COLUMNS, INFORMATION_SCHEMA.INDEXES, etc.).
4. Build a list of Column Names for later use.
5. Build a DDL statement to create the Table and Indexes. You may
also need the Constraint information if any.
6. Create the new table on the target database.
7. Open the source table (preferably using the SqlCeResultSet for
efficiency).
8. Open the target table (again using the SqlCeResultSet for
efficiency).
9. Loop through each record from the source table SqlCeResultSet.
10. Get the SqlCeUpdatableRecord for the target table SqlCeResultSet.
11. For each column (either using the column index or based on the
list of Column Names saved), set the SqlCeUpdatableRecord value to
respective value from the source SqlCeResultSet.
12. Perform Insert for the target SqlCeUpdatableRecord.
13. Done.
Coding something similar to this should take few hours. The most
difficult part will be to build the correct DDL statement to create
the target table given the variations you can have on the original
table schema.
Good luck.
- Jin
hai jin...
it's working now...thanks very much.. thanks.. thanks
.
- Prev by Date: Re: can't find pinvoke dll 'sqlceme30.dll'
- Next by Date: Re: table copy
- Previous by thread: Re: can't find pinvoke dll 'sqlceme30.dll'
- Next by thread: Re: table copy
- Index(es):
Relevant Pages
|
Loading