我试图将字符串传递给存储过程.我的代码是:
CREATE PROCEDURE AddCondition
@CondName varchar(50),
@CondDesc varchar(50)
AS
DECLARE @CondID int
--This code gets the next ID for the table
SET @CondID = (SELECT MAX([Condition ID]) FROM [dbo].[Tube Conditions]) + 1
SET @CondID = ISNULL(@CondID,1)
--This code adds records to the table
INSERT INTO [dbo].[Tube Conditions] ([Condition ID],[Condition Name],[Description])
VALUES (@CondID, @CondName, @CondDesc)
GO
Run Code Online (Sandbox Code Playgroud)
我尝试执行:
DECLARE @aName varchar(50), @aDesc varchar(50)
SET @aName = 'Lathed'
SET @aDesc = 'The tube has been lathed to size'
EXECUTE AddCondition @aName, @aDesc
GO …Run Code Online (Sandbox Code Playgroud)