Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server CE / April 2008

Tip: Looking for answers? Try searching our database.

table copy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
svnatraj@gmail.com - 27 Mar 2008 10:08 GMT
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...
ErikEJ - 28 Mar 2008 16:43 GMT
A possible approach is described here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1562812&SiteID=1

Signature

Erik Ejlskov Jensen, Mobile App Dev MCTS
Check out my SQL Compact blog at
http://erikej.blogspot.com

> hai...
>
[quoted text clipped - 9 lines]
> 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...
Jin - 28 Mar 2008 20:16 GMT
On Mar 27, 4:08 am, svnat...@gmail.com wrote:
> hai...
>
[quoted text clipped - 9 lines]
> 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
svnatraj@gmail.com - 01 Apr 2008 15:40 GMT
> On Mar 27, 4:08 am, svnat...@gmail.com wrote:
>
[quoted text clipped - 43 lines]
>
> - Jin

hai  jin...

it's working now...thanks very much.. thanks.. thanks
William (Bill) Vaughn - 30 Mar 2008 19:19 GMT
I discuss this issue in my ebook, but it does not include the newest (and
probably most appropriate approach) of using Synchronization Services. Once
the DDL is in place, syncing the tables should be fairly painless and easy
to code. VS 2008 might even do it for you by using the DataCache class.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

> hai...
>
[quoted text clipped - 9 lines]
> 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...
svnatraj@gmail.com - 01 Apr 2008 15:41 GMT
On Mar 30, 11:19 pm, "William \(Bill\) Vaughn"
<billvaRemoveT...@betav.com> wrote:
> I discuss this issue in my ebook, but it does not include the newest (and
> probably most appropriate approach) of using Synchronization Services. Once
[quoted text clipped - 32 lines]
>
> - Show quoted text -

hai .. william..

it's working...thankyou very much
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.