CTE中使用参数
把下面这个例子http://www.cnblogs.com/insus/articles/1962609.html,改用传入参数。
参考:
DECLARE @sex INT = 2;--1:femal; 2:male
WITH MaleEmp AS
(
SELECT * FROM [Employee] WHERE [SexId] = @sex
)
SELECT * FROM MaleEmp;
WITH MaleEmp AS
(
SELECT * FROM [Employee] WHERE [SexId] = @sex
)
SELECT * FROM MaleEmp;