Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. DECLARE @IsRowType1Req bit;
  2. DECLARE @IsRowType2Req bit;
  3.  
  4. DECLARE @tbl1 table (ID int, RowType varchar(50));
  5.  
  6. DECLARE @tmpTbl table (ID int, RowType varchar(50));
  7.  
  8. IF @IsRowType1Req = 1
  9. INSERT INTO
  10. @tmpTbl
  11. SELECT
  12. *
  13. FROM
  14. @tbl1
  15. WHERE
  16. RowType = 'RowType1' AND
  17. @IsRowType1Req = 1;
  18.  
  19. IF @IsRowType2Req = 1
  20. INSERT INTO
  21. @tmpTbl
  22. SELECT
  23. *
  24. FROM
  25. @tbl1
  26. WHERE
  27. RowType = 'RowType2' AND
  28. @IsRowType2Req = 1;
  29.  
  30. SELECT * FROM @tmpTbl;
  31.  
  32. DECLARE @IsRowType1Req bit;
  33. DECLARE @IsRowType2Req bit;
  34.  
  35. DECLARE @tbl1 table (ID int, RowType varchar(50));
  36.  
  37. SELECT
  38. *
  39. FROM
  40. @tbl1
  41. WHERE
  42. RowType = 'RowType1' AND
  43. @IsRowType1Req = 1
  44.  
  45. UNION
  46.  
  47. SELECT
  48. *
  49. FROM
  50. @tbl1
  51. WHERE
  52. RowType = 'RowType2' AND
  53. @IsRowType2Req = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement