Home Forums SQL Server 2008 SQL Server 2008 - General sql query to display a trailer record at the end in txt file (using batch file) RE: sql query to display a trailer record at the end in txt file (using batch file)

  • Hi ,

    I have this batch file as below. I need to update this to get the date without setting it as I have done in the second line of my code below.

    I want it to display automatically when I run this batch file every time. The date should be in yyyymmdd format.

    I tried lot of options with date parameters but couldn't get this right.

    Can you please help me with this..

    *** Batch file ********************************************

    set naic=1211610

    set filedatetime=18/10/2016 11:03

    set date=%filedatetime:~6,4%%filedatetime:~3,2%%filedatetime:~0,2%

    set filename=tnvin_%date%%naic%.txt

    set tnpath=C:\tnvintrailerSQLCMD -S SQLSANDBOX -E -Q "[SouthernTrust].[dbo].[P_tntr] "

    bcp [St].[dbo].[TmpTNVINTRInfo] out "%tnpath%%filename%" -c -T -S SQLSANDBOX

    SQLCMD -S SQLSANDBOX -E -Q "DROP TABLE [St].[dbo].[TmpTNVINTRInfo]"