Is there any other way to get a list of file names via T-SQL
other than
INSERT INTO @backups(filename)
EXEC master.sys.xp_cmdshell \'DIR /b c:\\som
The alternative to xp_cmdshell I came up is below:
My situation is a little unique in that I am attempting a poor man's log shipping. I have a folder (not the default SQL backup location) where transaction logs are deposited from a remote server. I am writing a c# app that loops through that directory and creates a comma delimited string of file names with paths (e.g. FooA.txn,FooB.txn,FooC.txn). I then feed this string into a stored procedure that I wrote which parses the string and inserts the file names into a temp table. Then I loop through the temp table restoring each transaction log in order.
Basically the C# app replaces xp_cmdshell and from the app I can call a stored procedure.