从存储过程中删除列名

时间:2018-08-30 08:50:27

标签: sql sql-server stored-procedures

我创建了一个用于插入查询的存储过程并运行代码。成功执行。现在,我想从该SP中删除一列。怎么做?

Sub Transferfile(wbTempPath As String, wbTargetPath As String)

Dim wb1 As Workbook
Dim wb_template As Workbook

Set wb1 = Workbooks.Open(wbTargetPath)
Set wb_template = Workbooks.Open(wbTempPath)

'/* Definition of the value range  */

wb_template.Sheets("Sheet1").Range("A2").Value = wb1.Sheets("Sheet1").Range("A2").Value
wb_template.Sheets("Sheet1").Range("A3").Value = wb1.Sheets("Sheet1").Range("A3").Value

wb_template.Sheets("Sheet1").Range("B2").Value = wb1.Sheets("Sheet1").Range("B2").Value
wb_template.Sheets("Sheet1").Range("B3").Value = wb1.Sheets("Sheet1").Range("B3").Value


wb1Name = Left(wb1.Name, InStr(wb1.Name, ".") - 1)
wb_template.SaveAs wb1.Path & "\" & wb1Name & "_New.xlsx"

wb1.Close False
wb_template.Close False

End Sub

我要从名为dbo.NewTerms_Insert的存储过程中删除 ListID 。怎么做?

4 个答案:

答案 0 :(得分:1)

只需ALTER删除该列的过程即可。

 ALTERPROCEDURE dbo.NewTerms_Insert
        @TimeCreated datetime ,
        @TimeModified datetime ,

    AS
    BEGIN
        SET NOCOUNT ON
        INSERT INTO dbo.NewTerms
        (

            TimeCreated  ,
            TimeModified  ,

        )
    VALUES
        (

            @TimeCreated  ,
            @TimeModified  ,

        )
END
GO

答案 1 :(得分:1)

Remove the column and alter the procedure:

ALTER PROCEDURE dbo.NewTerms_Insert
    @TimeCreated datetime ,
    @TimeModified datetime 

AS
BEGIN
    SET NOCOUNT ON
    INSERT INTO dbo.NewTerms
        (
            TimeCreated  ,
            TimeModified  

        )
    VALUES
        (
            @TimeCreated  ,
            @TimeModified  

        )
END
GO

答案 2 :(得分:0)

只需根据需要修改过程(更改其界面和/或其主体)。
在执行该脚本之前,请运行以下命令以确保删除了先前的版本:

IF OBJECT_ID('dbo.NewTerms_Insert', 'P') IS NOT NULL   
  DROP PROCEDURE dbo.NewTerms_Insert;  
GO  

我个人认为,最好在每个创建/修改过程的脚本的开头插入该片段。

答案 3 :(得分:0)

更改过程并从插入语句和值中删除列表列

Alter PROCEDURE dbo.NewTerms_Insert
      (
        @ListID nvarchar(50) ,
        @TimeCreated datetime ,
        @TimeModified datetime 
      )

    AS
    BEGIN
        SET NOCOUNT ON
        INSERT INTO dbo.NewTerms
            (

                TimeCreated ,TimeModified  

            )
        VALUES
            (

                @TimeCreated  ,
                @TimeModified  

            )
    END
    GO