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 |
|
kchrist
Starting Member
2 Posts |
Posted - 2005-05-16 : 11:14:41
|
| I want to assign each row of select results to sp parameters.For example i want to assign the value AttachmentNameUnique from the first row ofSELECT POAttachment.AttachmentNameUnique, POAttachment.POID, POAttachment.POAttachmentIDFROM PO INNER JOIN POAttachment ON PO.POID = POAttachment.POIDWHERE (PO.POID = 7514)AttachmentNameUnique POID POAttachmentIDTest.txt 7514 3819Test1.txt 7514 3820to Att1and the value AttachmentNameUnique from the second row to Att2.-------------------------------------------------------Any idea? |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-05-19 : 06:57:20
|
| [code]DECLARE @intRowCount int, @Att1 int, @Att2 intSELECT @intRowCount = 1SELECT @Att1 = CASE WHEN @intRowCount = 1 THEN AttachmentNameUnique ELSE @Att1, @Att2 = CASE WHEN @intRowCount = 2 THEN AttachmentNameUnique ELSE @Att2, @intRowCount = @intRowCount + 1FROM PO INNER JOIN POAttachment ON PO.POID = POAttachment.POIDWHERE (PO.POID = 7514)[/code]You will presumably need an ORDER BY for this to make sense?I haven't tested this, so no idea if it actually works, but if not it might need an UPDATE statement instead.Kristen |
 |
|
|
|
|
|