我试图编写一个存储过程并且我一直收到这个错误,我没有定义@address,我做了。我知道我错过了一件小事,我该如何改变呢?
CREATE PROCEDURE search_domaintable
@link nvarchar(50),
@address nvarchar(50)
AS
EXEC ('SELECT rank , ip FROM dbo.['+@link+'] where [address]=@address ');
我也试过这个:
CREATE PROCEDURE search_domaintable
@link nvarchar(50),
@address nvarchar(50)
AS
EXEC ('SELECT rank , ip FROM dbo.['+@link+'] where [address]=['+@address+']');
但它需要@address值作为列名并告诉我这样的列不存在。
答案 0 :(得分:0)
存储过程应该是这样的:
CREATE PROCEDURE search_domaintable
@link nvarchar(50),
@address nvarchar(50)
AS
EXEC ('SELECT rank , ip FROM dbo.['+@link+'] where address = ''' + @address + '''');