日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数据同步存储过程

發布時間:2025/4/16 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据同步存储过程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

USE [TKPOS_WuJing]
GO
/****** Object: StoredProcedure [dbo].[sp_get_saleData] Script Date: 07/21/2014 11:20:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author: 陳新光
-- Create date: 2014-05-28
-- Description: 獲取要上傳的銷售數據
/*
execute sp_get_saleData
*/
-- =============================================
/*
TSaleRecord = record // 銷售數據
recNo: string[40]; // guid
shopid: string[40]; // 門店編號
shopname: string[40];
billId: string[40]; // 單據編號
saleDate: TDatetime; // 銷售日期
goodsId: string[40]; // 商品編號
goodsName: string[40];
price: Currency; // 價格
qty: Single; // 數量
amount: Currency; // 金額
cookType: string[8]; // 班次
bigKindId: string[40]; // 大類編號
bigKindName: string[40];
smallKindId: string[40]; // 小類編號
smallKindName: string[40];
unitId: string[40]; // 計量單位編號
unitName: string[40];
vipId: string[40]; // 會員編號
vipName: string[40];
skyId: string[40]; // 收款員編號
skyName: string[40];
ywyId: string[40]; // 業務員編號
ywyName: string[40];
end;
*/
ALTER PROCEDURE [dbo].[sp_get_saleData]
--@bills varchar(400) output -- 將要上傳的銷售單號列表
AS
BEGIN
set nocount on
-- 獲取最近上傳數據的時間戳
declare @dd datetime
select @dd=LastUpload from sys_upload where UploadType='SaleData'
-- 將要上傳哪些銷售單
declare @billIds varchar(400)
declare @billId varchar(40)
DECLARE c1 CURSOR FOR
select top 5 SaleNo from Pos_Master where SaleDate>@dd -- 一次上傳5筆
open c1
FETCH NEXT FROM c1 INTO @billId
WHILE @@FETCH_STATUS = 0
BEGIN
if @billIds is null begin
set @billIds=''''+@billId+''''
end else begin
set @billIds=@billIds+','+''''+@billId+''''
end
FETCH NEXT FROM c1 INTO @billId
end
close c1
deallocate c1

declare @sql varchar(2000)
declare @time2 datetime
create table #tmp(
time2 datetime
)
set @sql='insert into #tmp select max(SaleDate) from Pos_Master where SaleNo in ('+@billids+')'
exec(@sql)
select @time2=time2 from #tmp

-- 獲取要上傳的銷售數據
set @sql='select b.SaleNo as billId,b.SaleDate,a.GoodsID,a.GoodsName,a.RetailPrice as price'
+',a.Qty,a.Amount,dbo.f_GetCookType(b.saleDate) as cooktype'
+',a.bigKindId,a.bigKindName,a.smallKindId,a.smallKindName'
+',a.UnitCode as unitid,a.Unit as unitname,'''' as vipid,'''' as vipname,b.Employee as skyid'
+',b.Createtor as skyname,'''' as ywyid,'''' as ywyname,'+''''
+convert(varchar,@time2,21)+''''+' as time2'
+' from pos_detail a'
+' inner join Pos_Master b on a.SaleNo=b.SaleNo'
+' where b.SaleNo in ('+@billIds+')'
exec (@sql)

drop table #tmp

set nocount off
END

轉載于:https://www.cnblogs.com/hnxxcxg/p/3858051.html

總結

以上是生活随笔為你收集整理的数据同步存储过程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。