SET @StartDate = NULL,
@InitialLoopValue=NULL,
@FinalLoopValue = NULL, @RootId = NULL, @MakeId = NULL, @CityId = NULL,
@CountOfCarsUpdated = NULL, @Url = NULL, @MakeName = NULL, @RootName = NULL,
@CityName = NULL, @Content = NULL, @SellInquiryId = NULL, @SellerType = NULL,@imei = NULL;
我有这么多变量,我收到了这个错误。
但是,当我为每个默认分配单独设置SET
时,它的工作正常,但这太详细了。
我该如何纠正?
答案 0 :(得分:7)
您可以使用SELECT
一次分配多个变量。
SELECT @StartDate = NULL,
@InitialLoopValue=NULL,
@FinalLoopValue = NULL, @RootId = NULL,
@MakeId = NULL, @CityId = NULL,
@CountOfCarsUpdated = NULL, @Url = NULL,
@MakeName = NULL, @RootName = NULL,
@CityName = NULL, @Content = NULL,
@SellInquiryId = NULL, @SellerType = NULL,@imei = NULL;
注意:未分配变量的默认值为NULL
,因此无需= NULL
。
DECLARE @v INT;
SELECT @v
-- NULL