Convertir una Sql a un Stored Procedure
Me puedes indiacar como trasformo esta SQL a un "Stored-Procedure y como debo hacer para que al ejecutarlo me solicite pasar los rangos del "Where"
( Que no sea fijo como en la SQL)
Query :
-------------------------------------
SELECT
' ' AS Expr1,'100' AS Expr,' ' AS Expr1,'0' AS Expr1,VMxCl_Periodo,'0' AS Expr1,
'0' AS Expr1,'0' AS Expr1,' ' AS Expr1,' ' AS Expr1,' ' AS Expr1,VMxCl_Cod_Articulo,
'CL01' AS Expr1,'CL10' AS Expr1,VMxCl_Cod_Cliente,' ' AS Expr1,'CL' AS Expr1,' ' AS Expr1,
'0' AS Expr1,' ' AS Expr1,Sum(VMxCl_VtaUnid) AS TotalUnidades
FROM dbo.sgn_VtaMesxCli
WHERE (VMxCl_Periodo >= 200401) AND (VMxCl_Periodo <= 200406)
GROUP BY VMxCl_Periodo,VMxCl_Cod_Articulo,VMxCl_Cod_Cliente
ORDER BY VMxCl_Periodo,VMxCl_Cod_Articulo,VMxCl_Cod_Cliente
-----------------------------------
De antemano gracias
( Que no sea fijo como en la SQL)
Query :
-------------------------------------
SELECT
' ' AS Expr1,'100' AS Expr,' ' AS Expr1,'0' AS Expr1,VMxCl_Periodo,'0' AS Expr1,
'0' AS Expr1,'0' AS Expr1,' ' AS Expr1,' ' AS Expr1,' ' AS Expr1,VMxCl_Cod_Articulo,
'CL01' AS Expr1,'CL10' AS Expr1,VMxCl_Cod_Cliente,' ' AS Expr1,'CL' AS Expr1,' ' AS Expr1,
'0' AS Expr1,' ' AS Expr1,Sum(VMxCl_VtaUnid) AS TotalUnidades
FROM dbo.sgn_VtaMesxCli
WHERE (VMxCl_Periodo >= 200401) AND (VMxCl_Periodo <= 200406)
GROUP BY VMxCl_Periodo,VMxCl_Cod_Articulo,VMxCl_Cod_Cliente
ORDER BY VMxCl_Periodo,VMxCl_Cod_Articulo,VMxCl_Cod_Cliente
-----------------------------------
De antemano gracias