Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello everyone ,
I am new to Stoared procedure as well as File Concept.Here I want access *.BAK Files from D:\Folder\ using stoared procedure .Here I have stoared *.BAK files to D:\Folder\ using stoared Procedure sucessfully .Now I want retrieve all *.BAK File from D:\Folder\ using stoared procedure and stoared into gridview along with details.

Please help me it's urgent
Thanks.
Posted
Updated 25-Nov-15 21:30pm
v2
Comments
Richard MacCutchan 26-Nov-15 3:32am    
What do you mean by "stored procedure" in this context?
SujataJK 26-Nov-15 6:19am    
I want stored procedure for retrieve list of files (*.BAK) from particular folder.
Richard MacCutchan 26-Nov-15 6:28am    
Yes, that is what your original question stated. But what is a "stored procedure" in this context, e.g. what programming language are you using?
SujataJK 26-Nov-15 6:33am    
C#
SujataJK 27-Nov-15 6:24am    
Here I got the following Script ,Which gives me all Backup file within particular Folder.Its correct but i want only 3 Latest File .So If anyone have idea ,then give me.



IF OBJECT_ID('tempdb..#DirectoryTree') IS NOT NULL
DROP TABLE #DirectoryTree;

CREATE TABLE #DirectoryTree (
id int IDENTITY(1,1)
,subdirectory nvarchar(512)
,depth int
,isfile bit);

INSERT #DirectoryTree (subdirectory,depth,isfile)
EXEC master.sys.xp_dirtree 'D:\Sujata\SALESDBBackup',1,1;

SELECT *--,ROW_NUMBER()over (order by id desc)
FROM #DirectoryTree
WHERE isfile = 1 AND RIGHT(subdirectory,4) = '.BAK'
ORDER BY id desc;
ELSE

GO

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900