Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @IsRowType1Req bit;
- DECLARE @IsRowType2Req bit;
- DECLARE @tbl1 table (ID int, RowType varchar(50));
- DECLARE @tmpTbl table (ID int, RowType varchar(50));
- IF @IsRowType1Req = 1
- INSERT INTO
- @tmpTbl
- SELECT
- *
- FROM
- @tbl1
- WHERE
- RowType = 'RowType1' AND
- @IsRowType1Req = 1;
- IF @IsRowType2Req = 1
- INSERT INTO
- @tmpTbl
- SELECT
- *
- FROM
- @tbl1
- WHERE
- RowType = 'RowType2' AND
- @IsRowType2Req = 1;
- SELECT * FROM @tmpTbl;
- DECLARE @IsRowType1Req bit;
- DECLARE @IsRowType2Req bit;
- DECLARE @tbl1 table (ID int, RowType varchar(50));
- SELECT
- *
- FROM
- @tbl1
- WHERE
- RowType = 'RowType1' AND
- @IsRowType1Req = 1
- UNION
- SELECT
- *
- FROM
- @tbl1
- WHERE
- RowType = 'RowType2' AND
- @IsRowType2Req = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement