Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 5th, 2013  |  syntax: None  |  size: 2.18 KB  |  views: 50  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SELECT [Theme].[PK_Theme], [Theme].[Name], [ThemeType].[Type]
  2. FROM [Theme]
  3. LEFT OUTER JOIN [ThemeType]
  4. ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType]
  5. JOIN [ProductTheme] ON [ProductTheme].[ThemeId]=[Theme].[PK_Theme]
  6. WHERE ProductTheme.ProductID LIKE @productParam
  7. AND ProductTheme.ThemeId = Theme.PK_Theme
  8. AND COALESCE([THEME].[THEMETYPEID], 'null') LIKE @assignedParam
  9. GROUP BY [Theme].[Name], [ThemeType].[Type], [Theme].[PK_Theme]
  10. ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 0 ELSE 1 END, [Theme].[Name]
  11.        
  12. Conversion failed when converting the varchar value 'NULL' to data type int.
  13.        
  14. AND COALESCE([THEME].[THEMETYPEID], 'null') LIKE @assignedParam
  15.        
  16. AND COALESCE([THEME].[THEMETYPEID], NULL) LIKE @assignedParam
  17.        
  18. AND COALESCE([THEME].[THEMETYPEID], 0) LIKE @assignedParam
  19.        
  20. SELECT  [Theme].[PK_Theme] ,
  21.                 [Theme].[Name] ,
  22.                 [ThemeType].[Type]
  23.         FROM    [Theme]
  24.                 LEFT OUTER JOIN [ThemeType] ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType]
  25.                 JOIN [ProductTheme] ON [ProductTheme].[ThemeId] = [Theme].[PK_Theme]
  26.         WHERE   ProductTheme.ProductID LIKE @productParam
  27.                 AND ProductTheme.ThemeId = Theme.PK_Theme
  28.                 AND 1 = CASE WHEN [THEME].[THEMETYPEID] IS NULL THEN 1
  29.                              WHEN [THEME].[THEMETYPEID] LIKE @param THEN 1
  30.                         END
  31.         GROUP BY [Theme].[Name] ,
  32.                 [ThemeType].[Type] ,
  33.                 [Theme].[PK_Theme]
  34.         ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 0
  35.                       ELSE 1
  36.                  END ,
  37.                 [Theme].[Name]
  38.        
  39. SELECT [Theme].[PK_Theme], [Theme].[Name], [ThemeType].[Type]
  40. FROM [Theme]
  41. LEFT OUTER JOIN [ThemeType]
  42. ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType]
  43. JOIN [ProductTheme] ON [ProductTheme].[ThemeId]=[Theme].[PK_Theme]
  44. WHERE ProductTheme.ProductID LIKE @productParam
  45. AND ProductTheme.ThemeId = Theme.PK_Theme AND [Theme].[ThemeTypeId] IS NOT NULL
  46. AND COALESCE([THEME].[THEMETYPEID], 'null') LIKE @assignedParam
  47. GROUP BY [Theme].[Name], [ThemeType].[Type], [Theme].[PK_Theme]
  48. ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 0 ELSE 1 END, [Theme].[Name]
clone this paste RAW Paste Data