Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql Query Problem

Author  Topic 

Kavyanjalisfriend
Starting Member

1 Post

Posted - 2010-10-07 : 06:38:45
Hi Friends,

I m trying to work on the query-procedure but finding it difficult to get the output.
I m passing parameter through front end want d result through parameter only.
Here is my Query-Procedure


Declare @InvoiceNo varchar(500)
SET @InvoiceNo = '10058984,10058986,10058982'

Select InvoiceNo ,Invoicedate,PartyName from InvoiceTable
Where Convert(Varchar,InvoiceNo )in (@InvoiceNo)

Desired Out Put

InvoiceNo,Invoicedate ,PartyName
10058984 ,02/02/2010 ,Reliance
10058982 ,02/02/2010 ,TCS
10058986 ,02/02/2010 ,Opera Town

If do like this (InvoiceNo has Int datatype)
Select InvoiceNo ,Invoicedate,PartyName from InvoiceTable
Where InvoiceNo in (10058984,10058986,10058982)
)
It gives me the desired out put as shown above but not with the parameter.

Please help me to get the solution
Thanks in advance
Regards,
Chandrakant







Chandrakant

Sachin.Nand

2937 Posts

Posted - 2010-10-07 : 06:45:16
[code]
Select InvoiceNo ,Invoicedate,PartyName,@InvoiceNo from InvoiceTable
Where InvoiceNo in (10058984,10058986,10058982)
[/code]

PBUH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-08 : 06:08:59
Select InvoiceNo ,Invoicedate,PartyName from InvoiceTable
Where ','+@InvoiceNo+',' like '%,'+Convert(Varchar(15),InvoiceNo)+',%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -