关于我的问题,我正在尝试这个选择语句并收到错误
Select * From
(SELECT * FROM FruitCrate WHERE FruitName IN (' +@FruitNames+ '))
WHERE FruitCrate.Eatable= 1
错误
关键字“WHERE”附近的语法不正确。
编辑
USE [DataBaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SPName]
(
@FruitNames
)
AS
exec('SELECT *
FROM FruitCrate
WHERE FruitName IN (' +@FruitNames+ ')
and Eatable = 1')