January 10, 2007 at 3:31 am
hello everyone, i have a table PinPackages
in this follwing fields are present
PinPackageCode
SupplierID
PackageName
PackagePrice
Description
SortOrder
now whenever i add a package then against a SupplierID, sortorder set to max+1, i mean to say if this supplier already have some packages and now add new then the sort order of this package is a new no .i.e the max + 1(previously max no +1 for making a new one)
here is my code plz check it , i m right or wrong as this works fine but plz experts checked it n tell me is it or not?
CREATE FUNCTION GetSortOrder (@SupplierID int)
RETURNS int
AS
BEGIN
declare @Return int
select @return= Max(SortOrder)
from PinPackages
where SupplierID=@SupplierID
set @Return=@Return+1
return @Return
END
Thanx in Advance.
January 10, 2007 at 4:49 am
set @return = isnull(@return, 0) + 1
N 56°04'39.16"
E 12°55'05.25"
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply