使用 SQLFiddle 中的过程访问时遇到问题
Trouble accessing with Procedure in SQLFiddle
我正在使用 SQL Server 2008 在 SQLFiddle 中构建查询。此查询是一个选择信息的过程。我不能 post 查询本身,但我可以 post 围绕过程的语法:
CREATE PROCEDURE BusinessInfo
@Variable VarChar(10)
AS
BEGIN
SELECT Info.*
FROM Table Info
WHERE Info.PersonKey = @Variable
ORDER BY Info.LastName
END
GO
EXECUTE BusinessInfo '1'
GO
问题是无论我做什么,一旦我创建过程,它就returns什么都没有。我什至构建了程序,说了 END GO,然后重新编写了整个程序查询,但它什么也没拉回来,然后我删除了程序,它拉回了我正在寻找的信息。我做错了什么?
如果您需要一个工作示例,这将适用于 SQLFiddle
中的任何架构
CREATE PROCEDURE Sample
AS
BEGIN
SELECT 'Information'
END
GO
EXECUTE Sample
GO
可能的解决方案:
1) 更改为(默认终止符为分号):SqlFiddleDemo
CREATE PROCEDURE Sample
AS
BEGIN
SELECT 'Information'
END;
EXECUTE Sample
2) 使用第 4 个按钮将查询终止符更改为 GO,您的示例将起作用。
选择 GO 作为终止符后的代码
CREATE PROCEDURE BusinessInfo
@Variable VarChar(10)
AS
BEGIN
SELECT Info.*
FROM Table Info
WHERE Info.PersonKey = @Variable
ORDER BY Info.LastName
END
GO
EXECUTE BusinessInfo '1'
GO
What's up with that [ ; ] button under each panel?
This obscure little button determines how the queries in each of the panels get broken up before they are sent off to the database. This button pops open a dropdown that lists different "query terminators." Query terminators are used as a flag to indicate (when present at the end of a line) that the current statement has ended. The terminator does not get sent to the database; instead, it merely idicates how I should parse the text before I execute the query.
Oftentimes, you won't need to touch this button; the main value this feature will have is in defining stored procedures. This is because it is often the case that within a stored procedure's body definition, you might want to end a line with a semicolon (this is often the case). Since my default query terminator is also a semicolon, there is no obvious way for me to see that your stored procedure's semicolon isn't actually the end of the query. Left with the semicolon terminator, I would break up your procedure definition into incorrect parts, and errors would certainly result. Changing the query terminator to something other than a semicolon avoids this problem.
我正在使用 SQL Server 2008 在 SQLFiddle 中构建查询。此查询是一个选择信息的过程。我不能 post 查询本身,但我可以 post 围绕过程的语法:
CREATE PROCEDURE BusinessInfo
@Variable VarChar(10)
AS
BEGIN
SELECT Info.*
FROM Table Info
WHERE Info.PersonKey = @Variable
ORDER BY Info.LastName
END
GO
EXECUTE BusinessInfo '1'
GO
问题是无论我做什么,一旦我创建过程,它就returns什么都没有。我什至构建了程序,说了 END GO,然后重新编写了整个程序查询,但它什么也没拉回来,然后我删除了程序,它拉回了我正在寻找的信息。我做错了什么?
如果您需要一个工作示例,这将适用于 SQLFiddle
中的任何架构CREATE PROCEDURE Sample
AS
BEGIN
SELECT 'Information'
END
GO
EXECUTE Sample
GO
可能的解决方案:
1) 更改为(默认终止符为分号):SqlFiddleDemo
CREATE PROCEDURE Sample
AS
BEGIN
SELECT 'Information'
END;
EXECUTE Sample
2) 使用第 4 个按钮将查询终止符更改为 GO,您的示例将起作用。
选择 GO 作为终止符后的代码
CREATE PROCEDURE BusinessInfo
@Variable VarChar(10)
AS
BEGIN
SELECT Info.*
FROM Table Info
WHERE Info.PersonKey = @Variable
ORDER BY Info.LastName
END
GO
EXECUTE BusinessInfo '1'
GO
What's up with that [ ; ] button under each panel?
This obscure little button determines how the queries in each of the panels get broken up before they are sent off to the database. This button pops open a dropdown that lists different "query terminators." Query terminators are used as a flag to indicate (when present at the end of a line) that the current statement has ended. The terminator does not get sent to the database; instead, it merely idicates how I should parse the text before I execute the query.
Oftentimes, you won't need to touch this button; the main value this feature will have is in defining stored procedures. This is because it is often the case that within a stored procedure's body definition, you might want to end a line with a semicolon (this is often the case). Since my default query terminator is also a semicolon, there is no obvious way for me to see that your stored procedure's semicolon isn't actually the end of the query. Left with the semicolon terminator, I would break up your procedure definition into incorrect parts, and errors would certainly result. Changing the query terminator to something other than a semicolon avoids this problem.