Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert values into multiple tables

Author  Topic 

chennaraaj
Starting Member

17 Posts

Posted - 2013-07-02 : 07:18:38

Hi,

i have a tables

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date
Table3 with T3ID, T3code, T3Name

i need to insert 500 dummy rows into Table1,

for each Table1 T1ID need to insert 10 dummy rows into Table2(500*10)

and for Table2 T2ID need to insert 50 dummy rows into Table3(500*10*50)




rk

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 07:23:34
you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

chennaraaj
Starting Member

17 Posts

Posted - 2013-07-02 : 07:34:26
quote:
Originally posted by visakh16

you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




ok ....

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date, T1ID
Table3 with T3ID, T3code, T3Name, T2ID




rk
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-07-02 : 08:11:52
quote:
Originally posted by chennaraaj

quote:
Originally posted by visakh16

you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




ok ....

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date, T1ID
Table3 with T3ID, T3code, T3Name, T2ID




rk

When you insert the data into Table2, what should be the values of T2ID, T2code? And, when you insert the data into Tble3, how should you generate the values of T3ID and T3code?
Go to Top of Page

chennaraaj
Starting Member

17 Posts

Posted - 2013-07-02 : 08:28:23
quote:
Originally posted by visakh16

you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs





hi visakh

i have a tables

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date ,T1ID
Table3 with T3ID, T3code, T3Name , T2ID, T1ID

i need to insert 500 dummy rows into Table1,

for each Table1 T1ID need to insert 10 dummy rows into Table2(500*10)

and for Table2 T2ID need to insert 50 dummy rows into Table3(500*10*50)


take the dummy data for other columns

rk
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 09:42:48
quote:
Originally posted by chennaraaj

quote:
Originally posted by visakh16

you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs





hi visakh

i have a tables

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date ,T1ID
Table3 with T3ID, T3code, T3Name , T2ID, T1ID

i need to insert 500 dummy rows into Table1,

for each Table1 T1ID need to insert 10 dummy rows into Table2(500*10)

and for Table2 T2ID need to insert 50 dummy rows into Table3(500*10*50)


take the dummy data for other columns

rk


Do you just want some random string and date data or is there some special rules for those Name,date etc fieldS?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

chennaraaj
Starting Member

17 Posts

Posted - 2013-07-02 : 22:53:12
quote:
Originally posted by visakh16

quote:
Originally posted by chennaraaj

quote:
Originally posted by visakh16

you dont have T1ID in Table2 neither have T2ID in Table3, so didnt understand how will relate the data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs





hi visakh

i have a tables

Table1 with T1ID , T1Name , T1Date
Table2 with T2ID, T2code, T2Name , T2Date ,T1ID
Table3 with T3ID, T3code, T3Name , T2ID, T1ID

i need to insert 500 dummy rows into Table1,

for each Table1 T1ID need to insert 10 dummy rows into Table2(500*10)

and for Table2 T2ID need to insert 50 dummy rows into Table3(500*10*50)


take the dummy data for other columns

rk


Do you just want some random string and date data or is there some special rules for those Name,date etc fieldS?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




take any static values for that 2 columns
like
Name='Text'
Date= Getdate()


rk
Go to Top of Page
   

- Advertisement -