Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How Can display tow result in select statement By Store Procdure :


SQL
ALTER proc  [dbo].[PrinttProducts_TBL] 
@Product_id int
 
as
select pt.Product_id ,pt.Product_name ,pt.Product_Price  
from dbo.Products_TBL pt
 inner join  tblcatProducts cp on cp.catId = pt.FK_catId inner join  StoresTBL st on pt.FK_Store_id = st.Store_id 
where Product_id=@Product_id and 

select DATEADD(year, 1, '2006-08-30') as 'Datenew'
Posted
Updated 16-Jun-15 7:55am
v2
Comments
virusstorm 16-Jun-15 13:23pm    
Do you me two (2) results?
Member 11280947 16-Jun-15 13:35pm    
yes
Member 11280947 16-Jun-15 13:36pm    
the first select statement
and second select statement

1 solution

If you remove the and between the two queries, it will return two result sets. The how to display them will depend on what you are using to execute the procedure (ADO.NET, Entity Framework, Management Studio, etc.).

SQL
ALTER proc [dbo].[PrinttProducts_TBL]
@Product_id int

as
select pt.Product_id ,pt.Product_name ,pt.Product_Price
from dbo.Products_TBL pt
inner join tblcatProducts cp on cp.catId = pt.FK_catId inner join StoresTBL st on pt.FK_Store_id = st.Store_id
where Product_id=@Product_id

select DATEADD(year, 1, '2006-08-30') as Datenew
 
Share this answer
 
Comments
Member 11280947 16-Jun-15 13:47pm    
ALTER proc [dbo].[PrinttProducts_TBL]
@Product_id int

as
select pt.Product_id ,pt.Product_name ,pt.Product_Price
from dbo.Products_TBL pt
inner join tblcatProducts cp on cp.catId = pt.FK_catId inner join StoresTBL st on pt.FK_Store_id = st.Store_id
where Product_id=@Product_id

select DATEADD(year, 1, '2006-08-30') as Datenew


i need to store this in parameter (second select statement)
virusstorm 16-Jun-15 13:50pm    
I'm having trouble following you on that. What do you mean store the second select statement in a parameter? How do you plan on accessing/consuming this value?
Member 11280947 16-Jun-15 13:56pm    
i use this store procedure in my report I trig to display for example: second year
virusstorm 16-Jun-15 14:00pm    
If you are using SQL Server Reporting Services, then what you are trying to do is not possible. Your only option would be to add your second statement as part of the column list in the first select. All of the rows would then have that value and you bind the report to the first row of the result set. This could have undesired effects if the report is empty.
Member 11280947 16-Jun-15 14:26pm    
i use crystal report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900