|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert multiple records using SP
Hello,
I'm new here, did do a seach, but could not find a satisfying solution. My question is: I've got a view, which generates a list of 3 records from a uge database. Now I want to insert these 3 records in another table. For now, I didn't get it working. This is what I start off with: CREATE Procedure user.spY AS DELETE FROM user.tableY GO Now I need an SP that fills the cleared table with 3 rows using a view. The view itself looks like this: CREATE VIEW user.viewXY AS SELECT TOP 3 Id, Name, City, Abon, Count FROM user.tableX WHERE (Abon = 3) ORDER BY Count This results, off course, in a view with 3 rows. These results I want to insert, through a stored procedure, into tableY. How can I do so? Cheers, Phi |
|
#2
|
|||
|
|||
|
Insert INTO tableX (FieldName1, FieldName2, FieldName3, FieldName4, FieldName5)
(SELECT TOP 3 Id, Name, City, Abon, Count FROM user.tableX WHERE (Abon = 3) ORDER BY Count) Or along these lines S- |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Insert multiple records using SP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|