September 20, 2015 at 9:24 am
I have a tabel name tbl_fr
it has several fields
[mr_recno]
,[bill_month]
,[batch_no]
,[mr_sdiv]
,[mr_sub_batch]
,[mr_cons_no]
,[mr_refNo]
i want query that takes Bill_month and Batch_no as input form the user to retrieve
specific month and batch no data.my database name is HHU.
September 20, 2015 at 10:19 am
kame707 (9/20/2015)
I have a tabel name tbl_frit has several fields
[mr_recno]
,[bill_month]
,[batch_no]
,[mr_sdiv]
,[mr_sub_batch]
,[mr_cons_no]
,[mr_refNo]
i want query that takes Bill_month and Batch_no as input form the user to retrieve
specific month and batch no data.my database name is HHU.
unless I am misreading your request.....this appears to be a simple select and where
try this to start
SELECT
mr_recno
, bill_month
, batch_no
, mr_sdiv
, mr_sub_batch
, mr_cons_no
, mr_refNo
FROM tbl_fr
WHERE bill_month = 'your filter here'
AND batch_no = 'your filter here';
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
September 20, 2015 at 11:25 am
thanks;but i want when i run the query it should ask me give the month and batch no.after giving the month and batch no thn it should display the result:
September 20, 2015 at 11:30 am
kame707 (9/20/2015)
thanks;but i want when i run the query it should ask me give the month and batch no.after giving the month and batch no thn it should display the result:
what front end application are you using?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
September 20, 2015 at 11:43 am
i m writing this query in SQLCMD.EXE to retrieve data.
September 20, 2015 at 11:59 am
kame707 (9/20/2015)
i m writing this query in SQLCMD.EXE to retrieve data.
suggest you start here
https://technet.microsoft.com/en-us/library/ms170207(v=sql.90).aspx
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
October 2, 2015 at 9:08 am
This link should help a lot https://msdn.microsoft.com/en-us/library/ms188714.aspx but one way you can do the prompting on the command line is using "set /p" (I'm assuming you're on the command line since you are using sqlcmd.exe) which will prompt the for input. You can create a batch file something like the below:
@echo off
set /p month=Month number:
set /p id=Batch ID:
sqlcmd -S server -d databasename -E -Q "SELECT * FROM dbo.tbl_fr WHERE bill_month = %month% AND batch_no = %id%" -o report.txt
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply