当前位置: 代码迷 >> Sql Server >> 存储过程拼接有关问题
  详细解决方案

存储过程拼接有关问题

热度:19   发布时间:2016-04-25 01:13:01.0
求救存储过程拼接问题
兄弟们,我有一个查询现在要移植到存储过程当中,代码为:
ALTER PROCEDURE [dbo].[test]
  @myWord nvarchar 
AS
DECLARE @tellMe VARCHAR(8000)
BEGIN
  -- routine body goes here, e.g.
  -- SELECT 'Navicat for SQL Server'
set @tellMe='SELECT top 5 * from news WHERE content LIKE('%'+@myword+'%')';
EXEC(@tellMe);
END
但始终报错:
数据类型varchar在modulo运算符中不兼容。
哪位朋友能帮我?

------解决方案--------------------
ALTER PROCEDURE [dbo].[test]
@myWord nvarchar (4000)
AS
DECLARE @tellMe VARCHAR(8000)
BEGIN
-- routine body goes here, e.g.
-- SELECT 'Navicat for SQL Server'
set @tellMe='SELECT top 5 * from news WHERE content LIKE(''%'+@myword+'%'')';
EXEC(@tellMe);
END

------解决方案--------------------
SQL code
ALTER PROCEDURE [dbo].[test] @myWord NVARCHAR AS      DECLARE @tellMe VARCHAR(8000)     BEGIN   -- routine body goes here, e.g.   -- SELECT 'Navicat for SQL Server'         SET @tellMe = 'SELECT top 5 * from news WHERE content LIKE(''%''+@myword+''%'')' ;             --PRINT @tellMe         EXEC(@tellMe) ;     END
------解决方案--------------------
up7锅
  相关解决方案