Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to add data to two table


how to add data to two table

Author
Message
santoshupadhayay87
santoshupadhayay87
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 2
i want to add three table to the datbase out of which two are from one table and one is of another table can anyone please help me with the same.
demonfox
demonfox
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1219 Visits: 1192
santoshupadhayay87 (10/16/2012)
i want to add three table to the datbase out of which two are from one table and one is of another table can anyone please help me with the same.

Its' not clear what you are are trying to convey ...

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
e4d4
e4d4
SSC Veteran
SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)

Group: General Forum Members
Points: 275 Visits: 2398
select into will make new table with the same column name and datatype, if you add false condition then only data schema will be copied without ady data
select * into NEWTABLE from OLDTABLE where 1=0


Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3046 Visits: 5478
santoshupadhayay87 (10/16/2012)
i want to add three table to the datbase out of which two are from one table and one is of another table can anyone please help me with the same.



Do you really think it's possible to answer? That sound like:
Go to somewhere, I don't know where. And bring me something, I don't know what!

However here is the trick:



SELECT TOP (50) PERCENT * INTO NewTable1
FROM MyOldTable1

SELECT * INTO NewTable2
FROM MyOldTable1 ot1
WHERE NOT EXISTS (SELECT 1
FROM NewTable1 nt1
WHERE nt1.[UniqueIdColumn(s)] = ot1.[UniqueIdColumn(s)])

SELECT * INTO NewTable3
FROM MyOldTable2




The above will split data from MyOldTable1 roughly in two half's and create two new tables from you old one :-)
And then create third new table from your second old one.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
demonfox
demonfox
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1219 Visits: 1192
Eugene Elutin (10/16/2012)
santoshupadhayay87 (10/16/2012)
i want to add three table to the datbase out of which two are from one table and one is of another table can anyone please help me with the same.



Do you really think it's possible to answer? That sound like:
Go to somewhere, I don't know where. And bring me something, I don't know what!


A good one Hehe

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
santoshupadhayay87
santoshupadhayay87
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 2
sorry everyone i mean the coloumn and not table
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3046 Visits: 5478
santoshupadhayay87 (10/16/2012)
sorry everyone i mean the coloumn and not table


That is much much more clear. ;-)
Now it's kind of:

Go to somewhere, but not there, and I still don't know where.
And bring me something, but not this thing, and I still don't know what!

Do you want similar answer?

What you really should do is:
Please, follow the link at the bottom of my signature. There you will find tips about how to post question on this forum to get most relevant and quickest help.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10765 Visits: 12019
Are you trying to add two columns to one table and one table to another table?

If so you wnat code like
ALTER Table1 add ColA type1 columnConstraints1, ColB type2 columnConstraints2;
ALTER Table2 add ColC type 3 columnConstraints3;


Obviously you have to provide the right tablenames, columnnames, and types, and also the right column constraints (if you want any). And if you add a column with column constraints that include a NOT NULL domain constraint it must also have a DEFAULT constraint (except that if the table is empty when you add the column you don't have to have a default for it if you don't want one).

Tom

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search