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.
Author |
Topic |
ajrev42
Starting Member
1 Post |
Posted - 2012-11-15 : 21:56:15
|
Hi Sqlteam member,Any help would be greatly appreciated. I created a batch file that prompts for theBegin 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 passingfrom the batch file. Any ideas why?@echo offSET /P Beg_Date=Enter Begin Date: SET /P End_Date=Enter End Date: d: cd "\Documents and Settings\" set NAME=patient_reg@echo onsqlcmd -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.sqlDECLARE @Beg_Date AS varchar(8)DECLARE @End_Date AS varchar(8)PRINT @Beg_Date <-- Nothing prints here so I am not passing the valuesPRINT @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 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|
|