I'm working on procedure, which uses OPENROWSET
.
I need to pass 1 varchar parameter into it. That's how I've decided to do that:
ALTER PROCEDURE [dbo].[GetId]
@designatio varchar
AS
BEGIN
DECLARE @SQLStr varchar(max)=
'select * FROM OPENROWSET(''SQLOLEDB'',''SQLSERVER'';''sss'';''sss''
,''select *
from db.dbo.table)
where DESIGNATIO = ''' + @designatio + ')'
EXECUTE(@SQLStr)
END
Everything is OK, but I get error when execute it:
exec GetId 'П-11792.00'
Incorrect syntax near 'П'
I've tried to cast passing parameter hard, so the error was the same, but
Incorrect syntax near 'П-11792.00'
Please, tell me, where am I wrong.