Author |
Topic |
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-04 : 23:44:58
|
Hellothis is my procedureALTER procedure [dbo].[vocuher]@VoucherNo int,@VoucherType varchar(50),@FromDate DATETIME,@ToDate DATETIMEasbeginselect vt.voucherTypeCode,vt.VoucherType,vm.VoucherNo,vm.VoucherDate,vm.Narrationfrom VoucherType vt left join VoucherMaster vm on vt.voucherTypeCode = vm.voucherTypeCodeleft join VoucherDetail vd on vm.voucherTypeCode = vd.voucherTypeCodewhere vm.VoucherDate BETWEEN @FromDate and @ToDateAND (ISNULL(@VoucherType,'')='' OR vt.VoucherType = @VoucherType)AND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)endi am getting problem the problem is when i execute from date its giving me the result but when i give vouchertype parameter aur voucher number parameter its giving me null resultplease help me out thanksimmad uddin ahmed |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 00:34:32
|
tryALTER procedure [dbo].[vocuher]@VoucherNo int,@VoucherType varchar(50),@FromDate DATETIME,@ToDate DATETIMEasbeginselect vt.voucherTypeCode,vt.VoucherType,vm.VoucherNo,vm.VoucherDate,vm.Narrationfrom VoucherType vt left join VoucherMaster vm on vt.voucherTypeCode = vm.voucherTypeCodeand vm.VoucherDate BETWEEN @FromDate and @ToDateAND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)left join VoucherDetail vd on vm.voucherTypeCode = vd.voucherTypeCodewhere (ISNULL(@VoucherType,'')='' OR vt.VoucherType = @VoucherType)end Unless you do like above the LEFT JOIN doesnt make any sense------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-05 : 02:21:55
|
i fix the query but i am getting problem after where clauseselect vm.VoucherTypeCode,vm.VoucherNo,vm.VoucherDate,vm.Narration, vt.VoucherType from VoucherMaster vmleft join VoucherDetail vd on vm.VoucherTypeCode = vd.VoucherTypeCodeleft join VoucherType vt on vt.VoucherTypeCode = vt.VoucherTypeCodewhere vm.VoucherDate BETWEEN @FromDate and @ToDateAND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)i am getting problem in this row AND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)when i search from voucherno its give me null result |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 03:18:20
|
quote: Originally posted by immad i fix the query but i am getting problem after where clauseselect vm.VoucherTypeCode,vm.VoucherNo,vm.VoucherDate,vm.Narration, vt.VoucherType from VoucherMaster vmleft join VoucherDetail vd on vm.VoucherTypeCode = vd.VoucherTypeCodeleft join VoucherType vt on vt.VoucherTypeCode = vt.VoucherTypeCodewhere vm.VoucherDate BETWEEN @FromDate and @ToDateAND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)i am getting problem in this row AND (ISNULL(@VoucherNo,'')='' OR vm.VoucherNo = @VoucherNo)when i search from voucherno its give me null result
show us how your data is. Otherwise we cant understand why its not giving you any result.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-05 : 03:25:51
|
my data is like this1st table VoucherMasterVoucherTypeCode---VoucherNo-----VoucherDate----NarrationJV----------------13140001------2013-03-26-----Sale Summary Closed.JV----------------13140002------2013-03-26-----Sale Summary Closed.JV----------------13140003------2013-03-28-----Stock TransferJV----------------13140004------2013-03-28-----Sale Summary Closed.----------------------------------2nd table VoucherDetailVoucherTypeCode----VoucherNoPU-----------------13140001PU-----------------13140001PU-----------------13140001PU-----------------13140002PU-----------------13140002------------------------------------3rd table VoucherTypeVoucherTypeCode-----VoucherTypeAD------------------ADVANCE VOUCHERBP------------------BANK PAYEMENT VOUCHERBR------------------BANK RECEIVED VOUCHERCO------------------Client OrderCP------------------CASH PAYMENT VOUCHERthis is the query select vm.VoucherTypeCode,vd.VoucherNo,vm.VoucherDate,vm.Narration, vt.VoucherType from VoucherMaster vmleft join VoucherDetail vd on vm.VoucherTypeCode = vd.VoucherTypeCodeleft join VoucherType vt on vt.VoucherTypeCode = vt.VoucherTypeCodewhere vm.VoucherDate BETWEEN @FromDate and @ToDateAND vm.VoucherNo = @VoucherNo thanks 4 the helpimmad uddin ahmed |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 04:21:41
|
As per your sample data there's no matching VoucherType values between the three tables. So it wont give you any matches.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-05 : 05:10:48
|
but the voucher type filed is matching values are also matching i didnt show please suggest me the querythanksimmad uddin ahmed |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 05:58:21
|
quote: Originally posted by immad but the voucher type filed is matching values are also matching i didnt show please suggest me the querythanksimmad uddin ahmed
show me some examples of that I dont have the time to play guessing game------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-05 : 06:03:00
|
example of data VoucherTypeCode---VoucherNo-----VoucherDate----NarrationJV----------------13140001------2013-03-26-----Sale Summary Closed.JV----------------13140002------2013-03-26-----Sale Summary Closed.JV----------------13140003------2013-03-28-----Stock TransferJV----------------13140004------2013-03-28-----Sale Summary Closed.PU----------------13140001------2013-03-27-----Stock Transfer----------------------------------2nd table VoucherDetailVoucherTypeCode----VoucherNoPU-----------------13140001PU-----------------13140001JV-----------------13140001PU-----------------13140002JV-----------------13140002------------------------------------3rd table VoucherTypeVoucherTypeCode-----VoucherTypeJV------------------ADVANCE VOUCHERBP------------------BANK PAYEMENT VOUCHERJV------------------BANK RECEIVED VOUCHERPU------------------Client OrderCP------------------CASH PAYMENT VOUCHERimmad uddin ahmed |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 06:05:59
|
so what should be your expected output for these?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-05 : 06:50:07
|
expected result will be like thisi use VoucherDate parameter from 2013-03-26 to 2013-03-27VoucherTypeCode-------VoucherType------------------VoucherNo------VoucherDate--------------------NarrationJV--------------------ADVANCE VOUCHER--------------13140001-------2013-03-26 00:00:00.000--------Sale Summary Closed.JV--------------------BANK RECEIVED VOUCHER--------13140001-------2013-03-26 00:00:00.000--------Sale Summary Closed.JV--------------------JOURNAL VOUCHER--------------13140001-------2013-03-26 00:00:00.000--------Sale Summary Closed.PU--------------------JOURNAL VOUCHER--------------13140001-------2013-03-27 00:00:00.000--------Sale Summary Closed.if i use voucherNo paramter then result should be like thisVoucherTypeCode-------VoucherType------------------VoucherNo------VoucherDate--------------------NarrationJV--------------------JOURNAL VOUCHER--------------13140001------2013-03-26 00:00:00.000-------Sale Summary Closed.JV--------------------JOURNAL VOUCHER--------------13140001------2013-03-26 00:00:00.000-------Sale Summary Closed.PU--------------------JOURNAL VOUCHER--------------13140001-------2013-03-27 00:00:00.000--------Sale Summary Closed.CP--------------------CASH PAYMENT VOUCHER---------13140001------2013-03-28 00:00:00.000-------CASH PAYMENT VOUCHERi hope u understand.immad uddin ahmed |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-05 : 08:24:59
|
where did you get JOURNAL VOUCHER? i cant even see such a value in your sample data.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
immad
Posting Yak Master
230 Posts |
Posted - 2013-11-06 : 05:51:58
|
why u want to know that where journal vocuher value come i just ask a simple query that if a user want to search from date then he use date parameter and if he wants to search from a voucher number not from a date then he use voucher number parameter.immad uddin ahmed |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-06 : 06:32:36
|
quote: Originally posted by immad why u want to know that where journal vocuher value come i just ask a simple query that if a user want to search from date then he use date parameter and if he wants to search from a voucher number not from a date then he use voucher number parameter.immad uddin ahmed
thats what i gave solution long before. then you responde thts not what you expected.So unless i get more info how can i suggest something.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|