Skip to content

Instantly share code, notes, and snippets.

@spockz
Created August 5, 2011 11:51
Show Gist options
  • Select an option

  • Save spockz/1127373 to your computer and use it in GitHub Desktop.

Select an option

Save spockz/1127373 to your computer and use it in GitHub Desktop.
USE [UUSurvey]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[Search_AlleCursussenActief_Opleiding]
@Q = N'INFO'
SELECT 'Return Value' = @return_value
GO
-- This still contains rows with CourseName = 'WIS...' not good!
CREATE PROCEDURE Search_AlleCursussenActief_Opleiding (@Q nvarchar)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT c.*, opl.OPLEIDING AS Programme, opl.NaamEn AS ProgrammeNameEN, opl.NaamNL AS ProgrammeNameNL, opl.TypeOpleiding AS [Type]
FROM [dbo].Cursussen AS c, [dbo].Opleidingen_Cursussen AS opl
WHERE
c.StartDate <= CURRENT_TIMESTAMP AND c.EndDate >= CURRENT_TIMESTAMP AND
c.CourseName = opl.CURSUS AND opl.Faculteit = c.Faculty AND
c.CourseName LIKE '%' + @Q + '%'
ORDER BY c.CourseName
END
SELECT DISTINCT c.*, opl.OPLEIDING AS Programme, opl.NaamEn AS ProgrammeNameEN, opl.NaamNL AS ProgrammeNameNL, opl.TypeOpleiding AS [Type]
FROM [dbo].Cursussen AS c, [dbo].Opleidingen_Cursussen AS opl
WHERE
c.StartDate <= CURRENT_TIMESTAMP AND c.EndDate >= CURRENT_TIMESTAMP AND
c.CourseName = opl.CURSUS AND opl.Faculteit = c.Faculty AND
c.CourseName LIKE '%INFO%'
ORDER BY c.CourseName
-- This gives the correct result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment