Monday, March 26, 2012

Help with SP

Hello,
I have the following two tables
tb_ProductIssue
issueID productID statusID Name
========================================
====
1 10 1 Error 256
2 12 2 Can't install
3 10 3 Constant Reboot
tb_status
statusID status_name
1 Open
2 Closed
3 Pending
I want to write a stored procedure that will retreive the issueID, productID
, status_name, and name
for a row in the tb_ProductIssue table. The stored procedure will have one
parameter, the
productID, to select any records in the tb_ProductIssue that correspond to t
he product. Here is
what I have so far, but I just stuck! Any help will be greatly appreciated
create procedure dbo.p_ProductIssuesGet
(
@.ProductID int
)
SELECT issueID, productID, statusID, name FROM tb_ProductIssue WHERE product
ID = @.ProductIDTry this
Exec('SELECT issueID, productID, statusID, name FROM tb_ProductIssue
WHERE productID = '+@.ProductID )|||Thanks for the help...but I found a way to do it with Inner Joins!
Ed_P. wrote:
> Hello,
> I have the following two tables
> tb_ProductIssue
> issueID productID statusID Name
> ========================================
====
> 1 10 1 Error 256
> 2 12 2 Can't install
> 3 10 3 Constant Reboot
> tb_status
> statusID status_name
> 1 Open
> 2 Closed
> 3 Pending
> I want to write a stored procedure that will retreive the issueID,
> productID, status_name, and name for a row in the tb_ProductIssue
> table. The stored procedure will have one parameter, the productID, to
> select any records in the tb_ProductIssue that correspond to the
> product. Here is what I have so far, but I just stuck! Any help will be
> greatly appreciated
> create procedure dbo.p_ProductIssuesGet
> (
> @.ProductID int
> )
> SELECT issueID, productID, statusID, name FROM tb_ProductIssue WHERE
> productID = @.ProductID|||Try this
Exec('SELECT issueID, productID, statusID, name FROM tb_ProductIssue
WHERE productID = '+@.ProductID )
Madhivanan

No comments:

Post a Comment