Click here to Skip to main content
15,910,130 members
Home / Discussions / C#
   

C#

 
GeneralRe: minimize form while closeing Pin
Polis Pilavas15-Apr-05 4:45
Polis Pilavas15-Apr-05 4:45 
GeneralLog4Net - changing appender configuration programmatically... Pin
devvvy14-Apr-05 16:03
devvvy14-Apr-05 16:03 
Generalserialization problem with a class that derives from dataset Pin
god4k14-Apr-05 15:57
god4k14-Apr-05 15:57 
GeneralRe: serialization problem with a class that derives from dataset Pin
turbochimp14-Apr-05 16:33
turbochimp14-Apr-05 16:33 
GeneralRe: serialization problem with a class that derives from dataset Pin
god4k14-Apr-05 18:01
god4k14-Apr-05 18:01 
GeneralRe: serialization problem with a class that derives from dataset Pin
god4k14-Apr-05 18:41
god4k14-Apr-05 18:41 
QuestionHow to copy tables? Pin
ben214-Apr-05 13:18
ben214-Apr-05 13:18 
AnswerRe: How to copy tables? Pin
turbochimp14-Apr-05 16:56
turbochimp14-Apr-05 16:56 
This question belongs on the ADO/SQL board. Since I wrote the reply to it before stopping to consider that fact, I'll post it here, but in the future, try to keep the questions on-topic, please.

Assuming your tables are on the same server instance (otherwise you'll have to further qualify the table objects, link servers etc.):

INSERT INTO [new database name].[owner id].[new table name]<br />
SELECT * FROM [old database name].[owner id].[old table name]

Example:
INSERT INTO sampledatabase2.dbo.table1<br />
SELECT * FROM sampledatabase1.dbo.table1


This example uses the '*' wildcard for brevity. You really should list out the columns in your own code.

As for what code you might use, I would suggest using a SqlConnection and a SqlCommand (using the ExecuteNonQuery method of the SqlCommand to execute the above syntax).

As an alternative to creating the schema by hand, and assuming you have appropriate permissions, you could also do something like:

SELECT [old database name].[owner id].[old table name].*<br />
INTO [new database name].[owner id].[new table name]<br />
FROM [old database name].[owner id].[old table name]

Example:
SELECT sampledatabase2.dbo.table1.* <br />
INTO sampledatabase1.dbo.tablefoo<br />
FROM sampledatabase2.dbo.table1


but explicitly creating the schema, or using a script created from the original is safer.


The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

GeneralRe: How to copy tables? Pin
ben219-Apr-05 11:50
ben219-Apr-05 11:50 
AnswerRe: How to copy tables? Pin
Alex Korchemniy14-Apr-05 19:00
Alex Korchemniy14-Apr-05 19:00 
GeneralBuilding Addin Pin
MAF14-Apr-05 12:00
MAF14-Apr-05 12:00 
GeneralRe: Building Addin Pin
Dave Kreskowiak14-Apr-05 16:52
mveDave Kreskowiak14-Apr-05 16:52 
GeneralInterting page break richTextBox Pin
Member 156981014-Apr-05 11:41
Member 156981014-Apr-05 11:41 
GeneralRe: Interting page break richTextBox Pin
Sebastian Schneider14-Apr-05 21:34
Sebastian Schneider14-Apr-05 21:34 
GeneralRe: Interting page break richTextBox Pin
Ashok Dhamija15-Apr-05 1:03
Ashok Dhamija15-Apr-05 1:03 
GeneralRe: Interting page break richTextBox Pin
Member 156981015-Apr-05 5:24
Member 156981015-Apr-05 5:24 
GeneralMake a TreeView expanded Pin
AngelFace14-Apr-05 10:58
AngelFace14-Apr-05 10:58 
GeneralRe: Make a TreeView expanded Pin
turbochimp14-Apr-05 11:15
turbochimp14-Apr-05 11:15 
GeneralRe: Make a TreeView expanded Pin
Kordzik14-Apr-05 11:23
Kordzik14-Apr-05 11:23 
GeneralRe: Make a TreeView expanded Pin
Kordzik14-Apr-05 11:24
Kordzik14-Apr-05 11:24 
GeneralAccess static function through System.Type Pin
RATC14-Apr-05 10:44
RATC14-Apr-05 10:44 
GeneralRe: Access static function through System.Type Pin
turbochimp14-Apr-05 11:36
turbochimp14-Apr-05 11:36 
GeneralRe: Access static function through System.Type Pin
RATC14-Apr-05 11:46
RATC14-Apr-05 11:46 
Generalopening special files Pin
bouli14-Apr-05 10:19
bouli14-Apr-05 10:19 
GeneralRe: opening special files Pin
Dave Kreskowiak14-Apr-05 16:37
mveDave Kreskowiak14-Apr-05 16:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.