November 18, 2009 at 3:38 am
Hi frnds....
I like to create store procedure for this stmt instead of using query
select * from tabname where sname like 'ram%' and sdate='10/24/2009'
I tried this procedure
CREATE procedure GET_COMM @qcname varchar(30),@reldate varchar(10)
as
DECLARE @SSQL AS VARCHAR(1000)
BEGIN
SET @SSQL='select * from tabname where sname LIKE '''+LTRIM(@qcname)+''' and sdate='''+LTRIM(@reldate)+''''
EXECUTE sp_executesql @SSQL
END
GO
But it throws err like this...
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
can anyone clear this..
Thanks in advance
November 18, 2009 at 3:52 am
DECLARE @SSQL AS VARCHAR(1000)
change @SSQL to NVARCHAR and it will work
read about sp_executesql on BOL.
-Vikas Bindra
November 18, 2009 at 9:29 am
Instead...
to make the code work with varchar variable..
you can change the code
from
EXECUTE sp_executesql @SSQL
to
Exec(@SSQL)
--Jus
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply