主頁(yè) > 知識(shí)庫(kù) > SQLSERVER數(shù)據(jù)庫(kù)升級(jí)腳本圖文步驟

SQLSERVER數(shù)據(jù)庫(kù)升級(jí)腳本圖文步驟

熱門標(biāo)簽:衛(wèi)星地圖標(biāo)注距離 外呼系統(tǒng)的話術(shù) 貴州外呼回?fù)芟到y(tǒng)是什么 競(jìng)圣地圖標(biāo)注服務(wù) 智能外呼系統(tǒng)需要多少錢 智能語(yǔ)音車載電話機(jī)器人 安陽(yáng)天音防封電銷卡 云南全自動(dòng)外呼系統(tǒng)公司 陽(yáng)光創(chuàng)信ai外呼獲客系統(tǒng)助力

只能遠(yuǎn)程協(xié)助的方式。我特意做了一個(gè)腳本,用電話指導(dǎo)客戶在SSMS里執(zhí)行一下腳本就可以了

1.0的數(shù)據(jù)庫(kù)跟1.1的數(shù)據(jù)庫(kù)的區(qū)別是1.1的數(shù)據(jù)庫(kù)里的其中一個(gè)[CT_OuterCard]表比1.0的多了6個(gè)字段,其他所有表都一樣

還有存儲(chǔ)過(guò)程增加了很多,其他都沒(méi)有改變

首先,先在公司的服務(wù)器數(shù)據(jù)庫(kù)上生成存儲(chǔ)過(guò)程腳本,數(shù)據(jù)庫(kù)是1.1版本的,下面的圖片里沒(méi)有說(shuō)明的,都是默認(rèn)設(shè)置,下一步即可

選中數(shù)據(jù)庫(kù)-》右鍵—》任務(wù)-》生成腳本

當(dāng)然,如果你的數(shù)據(jù)庫(kù)里有自定義函數(shù)的話,也可以勾選函數(shù),如果我們的數(shù)據(jù)庫(kù)沒(méi)有函數(shù),所以。。。

保存到新建查詢窗口

這一步做完了,然后編寫下面的SQL腳本

復(fù)制代碼 代碼如下:

--升級(jí)GPOS1.0到GPOS1.1數(shù)據(jù)庫(kù)的升級(jí)腳本 2013-7-4
USE [GPOSDB]
GO
------------------刪除所有存儲(chǔ)過(guò)程-------------------
--select * from sys.procedures

declare @sql varchar(4000)
set @sql=''
select @sql=@sql+'drop proc '+name+';   ' from sys.procedures
--print @sql
exec(@sql)

--------------------------------在[CT_OuterCard]表添加6個(gè)字段-------------------------------
ALTER TABLE [dbo].[CT_OuterCard] ADD [I_LimitTransCurrCount] INT  NOT NULL CONSTRAINT [DF_CT_OuterCard_I_LimitTransCurrCount]  DEFAULT ((0))
ALTER TABLE [dbo].[CT_OuterCard] ADD [I_LimitTransType] [int] CONSTRAINT [DF_CT_OuterCard_I_LimitTransType]  DEFAULT ((0))
ALTER TABLE [dbo].[CT_OuterCard] ADD [DE_LimitTransTotal] [decimal](18, 2) NOT NULL CONSTRAINT [DF_CT_OuterCard_DE_LimitTransTotal]  DEFAULT ((0))
ALTER TABLE [dbo].[CT_OuterCard] ADD [DE_LimitTransCurrTotal] [decimal](18, 2) NOT NULL CONSTRAINT [DF_CT_OuterCard_DE_LimitTransCurrTotal]  DEFAULT ((0))
ALTER TABLE [dbo].[CT_OuterCard] ADD [I_LimitCarNo] [int] NOT NULL CONSTRAINT [DF_CT_OuterCard_I_LimitCarNo]  DEFAULT ((0))
ALTER TABLE [dbo].[CT_OuterCard] ADD [D_LimitDate] [datetime] NOT NULL CONSTRAINT [DF_CT_OuterCard_D_LimitDate]  DEFAULT (getdate())
--------------------------------------------------------------------------------------------------------------
--把剛才在新建查詢窗口里生成的存儲(chǔ)過(guò)程腳本粘貼到下面
---------------------------創(chuàng)建GPOS1.1的所有存儲(chǔ)過(guò)程---------------------------------------------
USE [GPOSDB]
GO
/****** 對(duì)象:  StoredProcedure [dbo].[Report_GreaserSaleStat]    腳本日期: 07/04/2013 13:27:09 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO


CREATE PROC [dbo].[Report_GreaserSaleStat]
@StartDate datetime,
@EndDate datetime,
@Action int --0為交易記錄,1為班次記錄

   
            insert into #tmpCardAmoutStat
                (
                    VC_OC_CardNO,

            set @i=@i+1
        end

        truncate table #tmpCards
        insert into #tmpCards(VC_OC_CardNO)
        select VC_OC_CardNO from CT_OuterCard where isnull(VC_OC_Company,'')=''
        set @j=1
        select @cardcount=count(*) from #tmpCards
        while @j=@cardcount
        begin
            select @VC_OC_CardNO=VC_OC_CardNO from #tmpCards where  IndexId=@j
            insert into #tmpCardAmoutStat
                (
                    VC_OC_CardNO,
       

        insert into #tmpCardAmoutStat
            (
                VC_OC_CardNO,
                CompanyName,
                VC_OC_UserName,
                StartAmount,
                FillMoney,
                ConsumeSumVol,
                ConsumeMoney,
                SumConsumeSumVol,
                SumConsumeMoney,
                SumFillMoney

            )
        select
            null,
            null,
            '客戶卡小計(jì)',
            sum(StartAmount),
            sum(FillMoney),
            sum(ConsumeSumVol),

        truncate table #tmpCards
        insert into #tmpCards(VC_OC_CardNO)
        select VC_IC_CardNO from CT_InhouseCard where isnull(VC_IC_CardNO,'')>''
        set @j=1
        select @cardcount=count(*) from #tmpCards
        while @j=@cardcount
        begin
            select @VC_OC_CardNO=VC_OC_CardNO from #tmpCards where  IndexId=@j
            insert into #tmpCardAmoutStat
                (
                    VC_OC_CardNO,
                    CompanyName,
                    VC_OC_UserName,
                    StartAmount,
                    FillMoney,
                    ConsumeSumVol,
                    ConsumeMoney,
                    SumConsumeSumVol,
                    SumConsumeMoney,
                    SumFillMoney

                )
            select
                @VC_OC_CardNO,
                '員工卡',
                isnull((select VC_IC_UserName from CT_InhouseCard where VC_IC_CardNO=@VC_OC_CardNO),''),
                isnull((select top 1 DE_FD_Amount from CT_FuelingData where VC_FD_Cardno=@VC_OC_CardNO and (D_FD_DateTime=@StartDate) order by D_FD_DateTime desc),0),
                isnull((select sum(DE_A_AppendAmount) from CT_Append where VC_A_CardNO=@VC_OC_CardNO and (D_A_AppendDateTime between @StartDate and @EndDate)),0),
                isnull((select sum(DE_FD_Volume) from CT_FuelingData where VC_FD_Cardno=@VC_OC_CardNO and (D_FD_DateTime between @StartDate and @EndDate)),0),
                isnull((select sum(DE_FD_Amount) from CT_FuelingData where VC_FD_Cardno=@VC_OC_CardNO and (D_FD_DateTime between @StartDate and @EndDate)),0),
                isnull((select sum(DE_FD_Volume) from CT_FuelingData where VC_FD_Cardno=@VC_OC_CardNO),0),
                isnull((select sum(DE_FD_Amount) from CT_FuelingData where VC_FD_Cardno=@VC_OC_CardNO),0),
                isnull((select sum(DE_A_AppendAmount) from CT_Append where VC_A_CardNO=@VC_OC_CardNO),0)
            set @j=@j+1
        end

        insert into #tmpCardAmoutStat
            (
                VC_OC_CardNO,
                CompanyName,
                VC_OC_UserName,
                StartAmount,
                FillMoney,
                ConsumeSumVol,
                ConsumeMoney,
                SumConsumeSumVol,
                SumConsumeMoney,
                SumFillMoney

            )
        select
            null,
            null,
            '員工卡小計(jì)',
            sum(StartAmount),
            sum(FillMoney),
            sum(ConsumeSumVol),
            sum(ConsumeMoney),
            sum(SumConsumeSumVol),
            sum(SumConsumeMoney),
            sum(SumFillMoney)
        from
            #tmpCardAmoutStat
        where
            CompanyName='員工卡'
        ---計(jì)算員工卡匯總結(jié)束---
    end

    ----計(jì)算總匯總開(kāi)始---
    insert into #tmpCardAmoutStat
        (
            VC_OC_CardNO,
            CompanyName,
            VC_OC_UserName,
            StartAmount,
            FillMoney,
            ConsumeSumVol,
            ConsumeMoney,
            SumConsumeSumVol,
            SumConsumeMoney,
            SumFillMoney

        )
    select
        null,
        null,
        '總計(jì)',
        sum(StartAmount),
        sum(FillMoney),
        sum(ConsumeSumVol),
        sum(ConsumeMoney),
        sum(SumConsumeSumVol),
        sum(SumConsumeMoney),
        sum(SumFillMoney)
    from
        #tmpCardAmoutStat
    where
        (VC_OC_UserName='客戶卡小計(jì)' or VC_OC_UserName='員工卡小計(jì)') and VC_OC_CardNO is null
    update #tmpCardAmoutStat set EndAmount=StartAmount+FillMoney-ConsumeMoney
    ---計(jì)算總匯總結(jié)束---
    select * from  #tmpCardAmoutStat

    drop table #tmpCards
    drop table #tmpCompanys
    drop table #tmpCardAmoutStat
GO

--其他存儲(chǔ)過(guò)程省略。。。。。。。。。。。



然后把這個(gè)腳本發(fā)給客戶,讓客戶在SSMS里執(zhí)行一下就可以了

當(dāng)然如果某些表的主鍵更改了也很簡(jiǎn)單,使用alter table alter column語(yǔ)句修改一下就可以了

如有不對(duì)的地方,歡迎大家拍磚o(∩_∩)o

您可能感興趣的文章:
  • sqlserver數(shù)據(jù)庫(kù)移動(dòng)數(shù)據(jù)庫(kù)路徑的腳本示例
  • sqlserver數(shù)據(jù)庫(kù)大型應(yīng)用解決方案經(jīng)驗(yàn)總結(jié)
  • 將ACCESS數(shù)據(jù)庫(kù)遷移到SQLSERVER數(shù)據(jù)庫(kù)兩種方法(圖文詳解)
  • SQLSERVER數(shù)據(jù)庫(kù)備份后無(wú)法還原的解決辦法
  • sqlserver數(shù)據(jù)庫(kù)出現(xiàn)置疑的解決思路
  • SQLSERVER數(shù)據(jù)庫(kù)中的5173錯(cuò)誤解決方法
  • 將備份的SQLServer數(shù)據(jù)庫(kù)轉(zhuǎn)換為SQLite數(shù)據(jù)庫(kù)操作方法
  • sqlserver數(shù)據(jù)庫(kù)主鍵的生成方式小結(jié)(sqlserver,mysql)
  • 重命名SQLServer數(shù)據(jù)庫(kù)的方法
  • 自動(dòng)定時(shí)備份sqlserver數(shù)據(jù)庫(kù)的方法
  • sqlserver數(shù)據(jù)庫(kù)導(dǎo)入數(shù)據(jù)操作詳解(圖)

標(biāo)簽:河源 欽州 鄂爾多斯 寧夏 湘潭 營(yíng)口 周口 預(yù)約服務(wù)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《SQLSERVER數(shù)據(jù)庫(kù)升級(jí)腳本圖文步驟》,本文關(guān)鍵詞  SQLSERVER,數(shù)據(jù)庫(kù),升級(jí),腳本,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《SQLSERVER數(shù)據(jù)庫(kù)升級(jí)腳本圖文步驟》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于SQLSERVER數(shù)據(jù)庫(kù)升級(jí)腳本圖文步驟的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章