|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, October 16, 2012 6:17 AM
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.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
|
|
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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 1:54 PM
Points: 151,
Visits: 1,039
|
|
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
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
|
|
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 
~ demonfox ___________________________________________________________________ Wondering what I would do next , when I am done with this one
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, October 16, 2012 6:17 AM
Points: 2,
Visits: 2
|
|
| sorry everyone i mean the coloumn and not table
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:25 PM
Points: 7,110,
Visits: 7,184
|
|
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 Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|