存储过程

9/1/2015来源:SQL技巧人气:2068

存储过程

 1 SET NOCOUNT ON; 2   declare @taba table( 3             CityD int    , 4             Cityame  nvarchar    (50) 5         )     6    insert into @taba  select CityID,CityName from T_City  7     8    declare @CityD int    , 9             @Cityame  nvarchar    (50)10             11    while EXISTS(select * from @taba)12    begin13      select top 1 @CityD=CityD ,@Cityame= Cityame from @taba 14      Update  I_ipCity set CityID= @CityD   where  charindex(@Cityame,Area)   >015      delete top (1)   from @taba    16    end