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.
| Author |
Topic |
|
boab88
Starting Member
2 Posts |
Posted - 2009-04-24 : 10:32:07
|
| Hey This might be a coldfusion or it might be a sql question.I want to insert values into a table so I've got an sql statment like so:INSERT INTO UserRating (rating, playerid, fixtureid ,UserID)<cfoutput>VALUES (#therating#,#theid#,7,2000)</cfoutput>This works fine and inserts the values into the correct table, The problem is that #therating# and #theid# are lists of multiple values: so for example theid=564723891 and therating=1141141131Currently when I run the query the table ends up like this: Userid playerid fixtureid rating2000 564723891 7 1141141131I want it to loop through the values so that: Userid playerid fixtureid rating2000 5 7 12000 6 7 12000 4 7 4etc.I think the problem is because they are lists rather than when i normally take data out of a statment. Any ideas how to change it?Thanks Mike |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2009-04-25 : 03:03:33
|
| Hi Mike, Me too a CF developer.glad to see u here In mssql, u can achieve multiple insertion in the following way, will be the easiest methodINSERT INTO MyTable (FirstCol, SecondCol)SELECT 'First' ,1UNION ALLSELECT 'Second' ,2UNION ALLSELECT 'Third' ,3So using cfquery tag, u pls try something like below.<cfquery ur attributes> INSERT INTO MyTable (FirstCol, SecondCol) <cfloop> use list loop here to produce selects </cfloop></cfquery>Try pls and let me knowThanx... |
 |
|
|
|
|
|
|
|