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
 SQL Insert Multiple Rows

Author  Topic 

TCJohnson
Starting Member

9 Posts

Posted - 2009-10-05 : 14:21:42
Can someone please shed some light on what the best way to go about this task?

I have a form that has two teams on it and a field for their scores. I need to insert a row into a table for each incoming teamid (hometeamid and visitorteamid) and their respective scores. Can one SQL statement be used to write both rows or do I need to run an insert statement for each one? The fields in the table are

GameTypeID
GameID
TeamID
GoalsFor (this is the actual score)
GoalsAgainst (this is the other teams score)

The storing of scoring this way allows for the standings to be calculated later. Can anyone offer me some direction on this?


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-05 : 14:24:36
you can use single select iguess. what all values you get from form?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-05 : 14:24:52
INSERT INTO TABLE (Col list...)
SELECT @GameTypeID, @GameID, @HomeTeamID, @GoalsFor, @GoalsAgainst UNION ALL
SELECT @GameTypeID, @GameID, @VisitorTeamID, @GoalsFor, @GoalsAgainst


????




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -