I'm linking into an ingres database and whilst I got the openquery to work (with the help of someone on this site). I am now trying to do a like query where the wild card is a percentage sign. I've tried various things but can't get it to work. I'd appreciate any ideas, I've enclosed the query. The query below works for equals but I want to say where forename like @fname with a % on the end i.e Al%
declare @sname char(24)
declare @fname char(18)
declare @SQL nvarchar(2000)
set @sname = 'Evans'
set @fname = 'Al'
SET @SQL = 'insert into tt_appsp(surname,forename)SELECT surname,forename FROM OPENQUERY(??????,''select surname,forename from ????? where surname = '''''+@sname+''''' and forename = '''''+@fname+''''' '')'
EXEC sp_executesql @SQL
thanks
declare @sname char(24)
declare @fname char(18)
declare @SQL nvarchar(2000)
set @sname = 'Evans'
set @fname = 'Al'
SET @SQL = 'insert into tt_appsp(surname,forename)SELECT surname,forename FROM OPENQUERY(??????,''select surname,forename from ????? where surname = '''''+@sname+''''' and forename = '''''+@fname+''''' '')'
EXEC sp_executesql @SQL
thanks