--해당 상품에 GoodPubsCD, GoodPubs 없는 상품 찾아서 업데이트 하기 바람
Select OrderNum from Sql2.logics.dbo.OrderGood Where SellPrice = 0 and GoodPubsCD = 0 and CenterCD=1
and GoodVerify=1 and MallVerify=1 and ShopCD=0 and DoDate > '2003-06-13'
and DoStatusCD < 2001 Order by OrderNum
DECLARE OrderGood_Update_Cursor CURSOR FOR
Select bp.BookCD, bp.PublisherCD, b.Publisher from SQL1.shop.dbo.BookPublisher as bp inner join SQL1.Shop.Dbo.Book as b on bp.BookCD=b.BookCD
Where bp.BookCD in (Select GoodCD from Sql2.logics.dbo.OrderGood Where SellPrice = 0 and GoodPubsCD = 0 and CenterCD=1
and GoodVerify=1 and MallVerify=1 and ShopCD=0 --and DoDate > '2003-06-13'
and DoStatusCD < 2001)
OPEN OrderGood_Update_Cursor
Declare @GoodCD varchar(30), @GoodPubsCD int, @GoodPubs varchar(50)
FETCH NEXT FROM OrderGood_Update_Cursor INTO @GoodCD, @GoodPubsCD, @GoodPubs
WHILE @@FETCH_STATUS = 0
BEGIN
Update Sql2.logics.dbo.OrderGood Set GoodPubsCD=@GoodPubsCD, GoodPubs=@GoodPubs
Where DoStatusCD < 2001 and SellPrice = 0 and GoodPubsCD = 0 and CenterCD=1 and GoodVerify=1 and MallVerify=1
and ShopCD=0-- and DoDate > '2003-06-13'
And GoodCD = @GoodCD
FETCH NEXT FROM OrderGood_Update_Cursor INTO @GoodCD, @GoodPubsCD, @GoodPubs
END
CLOSE OrderGood_Update_Cursor
DEALLOCATE OrderGood_Update_Cursor