Hi all,
I have a table called TABLE1.
With following definition
Zone nvarchar(20)
Store nvarchar(20)
I have following records in that table:
Zone Store
0001 10000
0001 20000
0001 30000
0001 40000
0001 50000
0002 80000
I have created the following stored procedure:
--Start of procedure
Create Procedure TestProd
@Zone nvarchar(20)
as
select * from TABLE1
where Zone=@Zone
--End of procedure
Now,If i execute this procedure using the following statement:
Execute TestProd '0001'
I will get every record for zone 0001, I will get the following:
Zone Store
0001 10000
0001 20000
0001 30000
0001 40000
0001 50000
Now, I want to alter my Procedure in a way that even if i have thousands of zones, & in my exeucte statement if i don't pass anay parameter it will run all Zones records, & if I pass a parameter it should return records for only that particular zone.
Any quick idea how I can achieve this???
I would apprecitae if you write the code for the procedure & the EXEC statement for calling the procedure.
Thanks a million,
I have a table called TABLE1.
With following definition
Zone nvarchar(20)
Store nvarchar(20)
I have following records in that table:
Zone Store
0001 10000
0001 20000
0001 30000
0001 40000
0001 50000
0002 80000
I have created the following stored procedure:
--Start of procedure
Create Procedure TestProd
@Zone nvarchar(20)
as
select * from TABLE1
where Zone=@Zone
--End of procedure
Now,If i execute this procedure using the following statement:
Execute TestProd '0001'
I will get every record for zone 0001, I will get the following:
Zone Store
0001 10000
0001 20000
0001 30000
0001 40000
0001 50000
Now, I want to alter my Procedure in a way that even if i have thousands of zones, & in my exeucte statement if i don't pass anay parameter it will run all Zones records, & if I pass a parameter it should return records for only that particular zone.
Any quick idea how I can achieve this???
I would apprecitae if you write the code for the procedure & the EXEC statement for calling the procedure.
Thanks a million,