Contents
How to use the XP _ cmdshell extended procedure?
Xp_cmdshell and sqlcmd is an alternative to create complex stored procedures and scripts connecting to Azure and local databases. We will first create a SQL Server in Azure Portal. In Azure Portal, go to More Services>SQL Servers:
How to get the date of a file?
To avoid anything else from entering the #temp table in the first place, you can use forfiles, which allows you to specify a pattern (eliminating all the extra junk dir adds), specify a date (in this case any file with a modified date >= today), and also only return certain properties of the file (like the date), e.g.:
How to read date time from files with XP _ dirtree?
I’m working with a TSQL-script which uses xp_dirtree to pick up a file name from a directory with multiple bak-files, and then restores to a database using selected filename and the directory. However, I want to be able to select the MOST RECENT file from said folder.
Can you use dirtree on XP _ cmdshell instance?
Dirtree does not return that information. Xp_cmdshell does and it has to be enabled on your instance which your dba may, or may not, allow. If it is here is a solution:
How does XP cmdshell connect to Windows Server?
xp_cmdshell Proxy Account. When it is called by a user that is not a member of the sysadmin fixed server role, xp_cmdshell connects to Windows by using the account name and password stored in the credential named ##xp_cmdshell_proxy_account##.
Is the XP cmdshell feature enabled or disabled?
xp_cmdshell is a very powerful feature and disabled by default. xp_cmdshell can be enabled and disabled by using the Policy-Based Management or by executing sp_configure. For more information, see Surface Area Configuration and xp_cmdshell Server Configuration Option.
When does XP cmdshell return control to the caller?
xp_cmdshell operates synchronously. Control is not returned to the caller until the command-shell command is completed. xp_cmdshell can be enabled and disabled by using the Policy-Based Management or by executing sp_configure.