declare @id int; INSERT INTO Fotomall_Product_Category(categoryName, parentId, categoryNote,categoryLevel) values (@categoryName, @parentId,@categoryNote,@categoryLevel); set @id= SCOPE_IDENTITY(); if(@id>0) begin declare @i int; declare @seprator varchar(10); declare @propertyId nvarchar(200); set @seprator = ','; set @propertyId = rtrim( ltrim( @propertyIds )) set @i = charindex(@seprator, @propertyId) while @i >= 1 BEGIN INSERT INTO Fotomall_Product_CRelationP(categoryId,propertyId) VALUES(@id,left(@propertyId, @i - 1)); set @propertyId = substring(@propertyId, @i + 1, len(@propertyId)- @i) set @i = charindex(@seprator, @propertyId) END if @inputstr <> '' BEGIN INSERT INTO Fotomall_Product_CRelationP(categoryId,propertyId) VALUES(@id,@propertyId); END end