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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 query

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-04-10 : 10:42:17
[code]

i need a query to import the data from Student to three tables
(studentInfo,Studentsubject,StudentFee).

Ex:

Table:Student

Id name subject Feepaid status
--- ---- ------ -------- ------
1 sam Math 120 Passed


Execpted output

Table: studentInfo


ID Name
-- -----
1 Sam

Table:Studentsubject

ID subject
-- -------
1 Math

Table:StudentFee

ID Feepaid status
-- ------- ------
1 120 Passed

[/code]

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-04-10 : 11:35:29
What have you tried so far?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL or How to sell Used Cars
For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-04-10 : 14:29:36
INSERT
INTO
studentInfo
(
ID,
Name
)

(
Select
ID,
name
FROM
Student
)



INSERT
INTO Studentsubject
(
ID,
subject )

(SELECT
ID,
subject
FROM
Student
)

INSERT
INTO StudentFee
(
ID,
Feepaid,
status
)

(SELECT
ID,
Feepaid,
status
FROM
Student
)

Can yu suggest any other better solutions..
Go to Top of Page
   

- Advertisement -