declare @uid int = ##UserId:int##; declare @term nvarchar...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @uid int = ##UserId:int##;
declare @term nvarchar(max) = ##Text:string##;

declare @ptypes table (
  Id tinyint not null,
  Name text not null
);

insert into @ptypes
values
(1, 'question'),
(2, 'answer')

select
  id as [Post Link],
  format( creationdate, 'yyyy-MM-dd', 'en-US' ) as Created,
  (select Name from @ptypes where Id = posttypeid) as Type,
  body
from
  posts
where
  owneruserid = @uid
  and body like '%' + @term + '%'
order by
  Created desc

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results