batch-file

sqlcmd - How to get around column length limit without empty spaces?

馋奶兔 提交于 2021-01-27 04:09:06
问题 I'm trying to use sqlcmd on a windows machine running SQL Server 2005 to write a query to a csv file. The command line options we typically use are: -l 60 -t 300 -r 1 -b -W -h -1 However, the columns are getting truncated at 256 bytes. In an attempt to circumvent this, I tried using this command line option in place of -W: -y 8000 This captures the entire fields, but the problem with this method is that the file balloons up from just over 1mb to about 200mb due to all the extra space (I

sqlcmd - How to get around column length limit without empty spaces?

只愿长相守 提交于 2021-01-27 04:08:10
问题 I'm trying to use sqlcmd on a windows machine running SQL Server 2005 to write a query to a csv file. The command line options we typically use are: -l 60 -t 300 -r 1 -b -W -h -1 However, the columns are getting truncated at 256 bytes. In an attempt to circumvent this, I tried using this command line option in place of -W: -y 8000 This captures the entire fields, but the problem with this method is that the file balloons up from just over 1mb to about 200mb due to all the extra space (I

How to save text file contents into a temporary variable and echo it only if that text file is modified

谁都会走 提交于 2021-01-25 01:42:23
问题 Currently what I have checks to see if a text file has been modified, if it hasn't then recheck else type out the file contents. What im attempting to do is after the file contents have been typed out, store a temporary variable with the contents from that file and echo it ONLY when the file is modified. What im trying to achieve is get the content from a text file, type it to the console and when the file is modified append with new contents from the text file. How do i achieve this? heres

How to save text file contents into a temporary variable and echo it only if that text file is modified

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-25 01:41:25
问题 Currently what I have checks to see if a text file has been modified, if it hasn't then recheck else type out the file contents. What im attempting to do is after the file contents have been typed out, store a temporary variable with the contents from that file and echo it ONLY when the file is modified. What im trying to achieve is get the content from a text file, type it to the console and when the file is modified append with new contents from the text file. How do i achieve this? heres

Windows batch file delete files older than X days but leave a min of X files

穿精又带淫゛_ 提交于 2021-01-21 10:44:44
问题 I have see the older posts where you can delete files older than X days, such as this one Batch file to delete files older than N days. I'd like to add an additional filter to this so that if the backup I am running is not happening for 2 weeks, then it wouldn't delete all my backups. I know with this: forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path" That you can delete older than X days but how do I add the condition above and have it leave a minimum of Z files

How can I retrieve the seconds part of TIME in cmd?

谁说我不能喝 提交于 2021-01-21 06:09:28
问题 I'm trying to write a cmd script that gets the current date and time and formats it into a way that sqlserver can input it as a datetime . So far, I have: @echo off for /F "tokens=1-4 delims=/ " %%i in ('date /t') do ( set dow=%%i set mon=%%j set day=%%k set yr=%%l set mydate=%%j/%%k/%%l ) This prints out 10/22/2010 I have not been able to figure out how to get the time into a usable format. I tried working with time /t , but it only gives the hours and minutes, and I need the seconds also.

How to run a batch file in order to shutdown PC from C++ service on a Windows 10 machine?

耗尽温柔 提交于 2021-01-20 13:45:20
问题 I have a C++ program that runs as a service on a 64-bit Windows 10 machine. In this program, I want to execute a batch file to remotely switch off Pcs. I tried to use the function system() as follows : system("cmd.exe /C \"batchfile path""); system("shutdown /s /f /t 15 /m IPAdress"); In the second case, nothing happens. And in the first case, when I put a shutdown in my batch file, nothing happens however when I put a line like : echo Test >> D:\test\toto.txt The line is well executed

IF Exist How to setup sub folders in a batch file

為{幸葍}努か 提交于 2021-01-20 12:18:45
问题 I can't seem to make this code work Original Works if I make it solo and add files in same folder as the bat @echo off for %%a in (*.txt) do ren "%%a" "Tier 1) - %%a.tmp" ren *.tmp *. Trying to add it to my IF Exist bat file IF %ERRORLEVEL% EQU 6 ( @echo off IF EXIST "01_FileRename\Tier_1\Activate" ( for %%a in (*.txt) do ren "%%a" "Tier 1) - %%a.tmp" ren *.tmp *. I have 8 functions in my IF Exist bat file trying to add this function in what the code does 2004_Honda_ Accord.txt Tier 1 2004

IF Exist How to setup sub folders in a batch file

女生的网名这么多〃 提交于 2021-01-20 12:17:33
问题 I can't seem to make this code work Original Works if I make it solo and add files in same folder as the bat @echo off for %%a in (*.txt) do ren "%%a" "Tier 1) - %%a.tmp" ren *.tmp *. Trying to add it to my IF Exist bat file IF %ERRORLEVEL% EQU 6 ( @echo off IF EXIST "01_FileRename\Tier_1\Activate" ( for %%a in (*.txt) do ren "%%a" "Tier 1) - %%a.tmp" ren *.tmp *. I have 8 functions in my IF Exist bat file trying to add this function in what the code does 2004_Honda_ Accord.txt Tier 1 2004

store the output of powershell command in a variable

*爱你&永不变心* 提交于 2021-01-20 05:02:59
问题 The following commnad: $sun=PowerShell [DateTime]::Today.AddDays(-8).ToString('dd-MMM-yyyy') echo %sun % the output of the echo is PowerShell [DateTime]::Today.AddDays(-8).ToString('dd-MMM-yyyy') how do i get it to output something like 22-Sep-2013 回答1: You need to use for /f : for /f "usebackq" %%x in (`powershell "(Get-Date).AddDays(-8).ToString('dd-MMM-yyyy')"`) do set sun=%%x 来源: https://stackoverflow.com/questions/19089736/store-the-output-of-powershell-command-in-a-variable