CREATE PROCEDURE CityAdd
@cityname varchar(50)
@partname varchar(50)
AS
DECLARE @citymaxid int
DECLARE @partid int
SELECT @partid=PartId
FROM TravelPart
WHERE PartName=@partname
SELECT TOP 1 @citymaxid=CityId
FROM TravelCity
ORDER BY CityId DESC
IF @citymaxid>0
INSERT INTO TravelCity( CityId, CityName, PartId )
VALUES( @citymaxid+1, @cityname, @partid )
ELSE
INSERT INTO TravelCity( CityId, CityName, PartId )
VALUES( @0, @cityname, @partid )
GO
参数后要加逗号,晕了我半个小时
浙公网安备 33010602011771号