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 2000 Forums
 Transact-SQL (2000)
 multi select drop down

Author  Topic 

qwertyjjj
Posting Yak Master

131 Posts

Posted - 2008-08-14 : 06:12:09
I need to change this procedure to accept multi selects from a webpage drop down. What's the best way as I only know how to add single variables in SQL and dynamically this could be 2 or more multi selects with the @Code, e.g. 12 and 44


CREATE PROCEDURE web_TopClientsByCompanyCode (

@topnum int,
@Code int,
@month int,
@sector int,
@monthend int

)

AS

SET ROWCOUNT @topnum

SELECT Groups.CompanyName,
Groups.ParentGroup,
sum(Amounts.Turnover) AS Turnover,
ClientSectors.Description,
Groups.TAP,
Groups.KAM
FROM

(SELECT max(companyname) as companyname, parentgroup, ClientSector, TAP, KAM
from companies group by parentgroup, ClientSector, TAP, KAM ) Groups

LEFT JOIN (

SELECT C.ParentGroup,
[amtin loccur] AS Turnover
FROM Companies C
LEFT JOIN zarinvreg ON zarinvreg.Customer = C.AccountCode
WHERE monthdata <= @month
AND monthdata >= @monthend--@month-11 --this gives us 12 months
AND C.CompanyName <> '-'
AND C.CompanyName is not null
AND Cocd = @Code
) Amounts ON Groups.ParentGroup = Amounts.ParentGroup

LEFT JOIN ClientSectors ON ClientSectors.ID = Groups.ClientSector

WHERE Amounts.Turnover is not null
AND (ClientSectors.ID = @sector OR ISNULL(@sector ,'')='')

GROUP BY Groups.CompanyName,
Groups.ParentGroup,
ClientSectors.Description,
Groups.TAP,
Groups.KAM
ORDER BY Amounts.Turnover desc

SET ROWCOUNT 0




GO

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-14 : 06:24:49
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -