由于某种原因,每次我运行exec
communications_getCode @telCode='MX'
我得到空结果。我知道我错过了一些东西,因为如果我跑步
Select * from tbl_telCode where code = 'MX'
我得到结果(准确地说是1)。但是,如果我尝试使用该程序,则会得到空白的结果
CREATE PROCEDURE dbo.communications_getCode
@telcode varchar
AS
SELECT
id, code, detail
FROM
tbl_telCode
WHERE
[code] = @telcode;
我不知道我在想什么。
答案 0 :(得分:0)
声明中的Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Debug.Print KeyAscii
If (KeyAscii >= 48 And KeyAscii <= 57) Then
Debug.Print "number"
ElseIf KeyAscii = 44 Then
Debug.Print "comma"
If Application.DecimalSeparator = "." Then
Debug.Print "switching to period..."
KeyAscii = 46
End If
ElseIf KeyAscii = 46 Then
Debug.Print "period"
If Application.DecimalSeparator = "," Then
Debug.Print "switching to comma..."
KeyAscii = 44
End If
Else
Debug.Print "other"
KeyAscii = 0
End If
End Sub
默认为varchar
。当您传递更长的字符串时,它将被截断为一个字符。
在SQL Server中,总是为用户提供带字符串定义的长度:
varchar(1)
请注意,存储过程的主体包装在CREATE PROCEDURE dbo.communications_getCode (
@telcode varchar(255)
) AS
BEGIN
SELECT id, code, detail
FROM tbl_telCode
WHERE [code] = @telcode;
END;
/ BEGIN
中。我认为这是一种有用的做法。
此外,没有理由为此定义存储过程。我认为最好将其定义为一个函数。