小编Dav*_*vid的帖子

在 SQL 中声明多个表变量时出错

我在 Microsoft SQL Server 中声明多表变量时遇到问题。试图用逗号分隔表格,但似乎给了我一些语法错误。

代码看起来像这样。将代码显示为示例和图片,以便您查看错误标记:

DECLARE
@StructuredProducts TABLE(
    StructuredProductId INT
    ,ArrangerIdv2 INT
    ,ISIN VARCHAR(50)
    ,InstrumentId INT
    ,Caption VARCHAR(100)
    ,DbRegDate DATE
    ,EndDate DATE
),
@PriceDataOld TABLE(
    StructuredProductId INT
    ,FinalDate DATE
    ,FinalPriceDate DATE
    ,FinalPrice DECIMAL(9,3)
    ,FinalPriceSek DECIMAL(9,3)
),
@PriceDataEarlyExercise TABLE(
    StructuredProductId INT
    ,EEDate DATE
    ,EEPriceDate DATE
    ,EEPrice DECIMAL(9,3)
    ,EEPriceSek DECIMAL(9,3)
),
@PriceDataActive TABLE(
    StructuredProductId INT
    ,ActiveDate DATE
    ,ActivePriceDate DATE
    ,ActivePrice DECIMAL(9,3)
    ,ActivePriceSek DECIMAL(9,3)
)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

sql sql-server

4
推荐指数
1
解决办法
1255
查看次数

Excel VBA 在同一过程中处理多个错误

我以前在 VBA 中成功使用过错误处理,但是当尝试使用几个错误处理块时,我不知道如何去做。

我写的代码是这样的:

...

  On Error GoTo ErrorHandler1
  shpArrow1.Left = shpLine.Left + shpLine.Width * Min(Sqr(Calculations.Range("cVolProduct").value / Calculations.Range("cVolRefIndices").value), 2) / 2 - shpArrow1.Width / 2
  shpTag1.Left = shpLine.Left + shpLine.Width * Min(Sqr(Calculations.Range("cVolProduct").value / Calculations.Range("cVolRefIndices").value), 2) / 2 - shpTag1.Width / 2
  shpArrow2.Left = shpLine.Left + shpLine.Width * Min(Sqr(Calculations.Range("cVolUnderlyings").value / Calculations.Range("cVolRefIndices").value), 2) / 2 - shpArrow2.Width / 2
  shpTag2.Left = shpLine.Left + shpLine.Width * Min(Sqr(Calculations.Range("cVolUnderlyings").value / Calculations.Range("cVolRefIndices").value), 2) / 2 - shpTag2.Width / 2
  shpIndexLine.Left = shpLine.Left + shpLine.Width / 2 …
Run Code Online (Sandbox Code Playgroud)

error-handling excel vba

3
推荐指数
1
解决办法
2万
查看次数

在 Excel VBA 中检查对象是否为 Null

我无法检查从 SQL 导入到 Excel 的值是否为 Null。在调试模式下,我可以看到分配的值为 Null,即不是字符串“Null”。在我的代码示例中尝试过is Nothing,但也尝试过isEmpty和= "Null"。

这是下面的代码中的If dbList(2) Is Nothing Then 行,我遇到了问题。

如何检查记录集是否为空?

...
Dim CmdSP As New ADODB.Command
CmdSP.CommandType = adCmdText
CmdSP.CommandText = "SELECT FundName, FundId, SRL.Comment FROM XXX SRL ON XXX = XXX ORDER BY FundName ASC"

CmdSP.ActiveConnection = dbConn

Dim dbList As ADODB.Recordset
Set dbList = CmdSP.Execute

Dim row As Integer
row = 1
While Not dbList.EOF
    DataStorage.Range("dsFundsTopLeft")(row, 2) = dbList(0)
    DataStorage.Range("dsFundsTopLeft")(row, 3) = …
Run Code Online (Sandbox Code Playgroud)

sql excel vba

2
推荐指数
1
解决办法
6990
查看次数

标签 统计

excel ×2

sql ×2

vba ×2

error-handling ×1

sql-server ×1