Register for your free account! | Forgot your password?

You last visited: Today at 10:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Question about SQL DB

Discussion on Question about SQL DB within the SRO Private Server forum part of the Silkroad Online category.

Reply
 
Old   #1
 
eminemsjunge's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 169
Received Thanks: 17
Question about SQL DB

Hello Guys i have a little Question.
I want to add a Table from one Database into an other DB can anyone help me with this ?
eminemsjunge is offline  
Old 05/30/2013, 16:47   #2
 
Schickl's Avatar
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,064
Received Thanks: 539
You can genereate a script to get the structure of the table and just run that again in the target db
The following code then copies the contents from one table to the other one
Code:
INSERT INTO <target db>.dbo.<target table>
SELECT * --you shouldn't use *, especially if you have an identity column and IDENTITY_INSERT is OFF, so specify columns
FROM <source db>.dbo.<source table>
[WHERE ...]
Schickl is offline  
Old 05/30/2013, 18:45   #3
 
eminemsjunge's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 169
Received Thanks: 17
Can you help me via TV ?
eminemsjunge is offline  
Old 05/30/2013, 18:54   #4
 
Schickl's Avatar
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,064
Received Thanks: 539
I'm pretty busy atm, so no, sorry

I found out about an easier way to do what you want(didn't know about that method)

Code:
CREATE TABLE <target db>.dbo.<table name>
AS ( SELECT *
       FROM <source db>.dbo.<table name>
       [WHERE ...]
     )
That makes it way easier
Just insert the names(the WHERE clause is optional of course)
Schickl is offline  
Thanks
1 User
Old 05/30/2013, 22:33   #5
 
eminemsjunge's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 169
Received Thanks: 17
I will try it thanks

dont work for me
eminemsjunge is offline  
Old 05/31/2013, 00:48   #6
 
elite*gold: 0
Join Date: Mar 2007
Posts: 849
Received Thanks: 667
Delete them table from the target database.
Drop table TARGETDB.dbo.TABLENAME

Select * INTO TARGETDB.dbo.TABLENAME FROM OLDDB.dbo.TABLENAME
royalblade is offline  
Old 05/31/2013, 09:07   #7
 
Schickl's Avatar
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,064
Received Thanks: 539
Quote:
Originally Posted by eminemsjunge View Post
I will try it thanks

dont work for me
how does your command look like exactly?

If the table already exists in the target db you will have to drop it(just like royalblade said)
The second command he posted won't work if you drop the table(because that's just a normal insert statement) so you have to use the create table I posted
Schickl is offline  
Reply




All times are GMT +1. The time now is 10:32.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.