Make Stored procedure in sql server [Resolved]

Posted by Self-innovator under Sql Server on 12/27/2011 | Points: 10 | Views : 1159 | Status : [Member] | Replies : 4
Hi pls help me to generate the following query as sp in sql server
strQRY = "SELECT [Orders].[CustomerID],[Orders].[OrderID]," +
"[Orders].[ShipAddress],[Orders].[Freight],[Orders].[ShipName] FROM [Orders]" +
" WHERE [Orders].[CustomerID] = '" + strCustometId + "'" +
"UNION ALL " +
"SELECT '" + strCustometId + "','','','','' FROM [Orders] WHERE [Orders].[CustomerID] = '" + strCustometId + "'" +
"HAVING COUNT(*)=0 " + strSort;
I'll be very thank ful...

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Suvendu on: 12/27/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved

CREATE PROCEDURE [dbo].[spCustomerOrders]

(
@CustmerID NVARCHAR(10),
@Sort INT
)
AS
BEGIN
SELECT [Orders].[CustomerID],[Orders].[OrderID],[Orders].[ShipAddress],[Orders].[Freight],[Orders].[ShipName] FROM [Orders]
WHERE [Orders].[CustomerID] = @CustmerID
UNION ALL
SELECT @CustmerID,'','','','' FROM [Orders]
WHERE [Orders].[CustomerID] = @CustmerID
HAVING COUNT(*)=0+ @Sort
END


I hope this will helps..
Please let me know if i am missing something..
if your problem is resolved, mark it as answer.

Thanks

Self-innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-innovator on: 12/28/2011 [Member] Bronze | Points: 25

Up
0
Down
thanks...suvend..

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suvendu on: 12/28/2011 [Member] Starter | Points: 25

Up
0
Down
You are most welcome..

Please mark this as answer.

Thanks.

Self-innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response