关于SQL存储过程问题 急,急,急
ALTER PROCEDURE [dbo].[Report1]
@StrITEM_NO nvarchar(80),
@StrVENDOR_ID nvarchar(80)
AS
DECLARE @SqlTemp nvarchar(80);
BEGIN
SET @SqlTemp = 'SELECT * FROM IN_INVVEND_TBL ';
IF ((@StrITEM_NO IS NOT NULL) AND (@StrVENDOR_ID IS NOT NULL))
SET @SqlTemp = @SqlTemp + ' WHERE((ITEM_NO= '+@StrITEM_NO+ ')) AND (VENDOR_ID = '+@StrVENDOR_ID+ ')) ';
ELSE IF ((@StrVENDOR_ID IS NOT NULL) AND (@StrITEM_NO IS NULL))
SET @SqlTemp = @SqlTemp + ' WHERE (VENDOR_ID = '+@StrVENDOR_ID+ ') ';
ELSE IF ((@StrITEM_NO IS NOT NULL) AND (@StrVENDOR_ID IS NULL))
SET @SqlTemp = @SqlTemp + ' WHERE(ITEM_NO= ' ' '+@StrITEM_NO+ ' ' ') ';
PRINT @SqlTemp
exec Report1
END
------解决方案--------------------exec(@SqlTemp)
------解决方案--------------------exec(@sqltemp)
------解决方案--------------------过程中你的单引号有缺少的地方