|
ajrev42
Starting Member
1 Posts |
Posted - 11/15/2012 : 21:56:15
|
Hi Sqlteam member,
Any help would be greatly appreciated.
I created a batch file that prompts for the Begin Date and End Date as shown below. In the .SQL program I declare the variables, however, when I run Print statements, the values are not passing from the batch file. Any ideas why?
@echo off
SET /P Beg_Date=Enter Begin Date: SET /P End_Date=Enter End Date:
d: cd "\Documents and Settings\" set NAME=patient_reg
@echo on
sqlcmd -s"|" -w2000 -E -Sngvrsql -dNGProd -i%NAME%.sql -v Beg_Date = '%Beg_Date%' -v End_Date = '%End_Date%' -o%NAME%_temp.txt
This the sql where I declare the variables:
Patient_Reg.sql
DECLARE @Beg_Date AS varchar(8) DECLARE @End_Date AS varchar(8)
PRINT @Beg_Date <-- Nothing prints here so I am not passing the values
PRINT @End_Date
--- <more code> where Case When Len(DATEPART(mm,pe.enc_timestamp)) = 1 Then '0' + Convert(Varchar (1),DATEPART(mm,pe.enc_timestamp)) Else Convert(Varchar (2),DATEPART(mm,pe.enc_timestamp)) end + Case When Len(DATEPART(dd,pe.enc_timestamp)) = 1 Then '0' + Convert(Varchar (1),DATEPART(dd,pe.enc_timestamp)) Else Convert(Varchar (2),DATEPART(dd,pe.enc_timestamp)) end + Convert(Varchar (4),DATEPART(yy,pe.enc_timestamp))in (@Beg_Date, @End_Date) <--- Where I substitute the input params
|
|