Refer the article for fetching files from database as Byte Array (Byte[]).
Save and Retrieve Files from SQL Server Database using ASP.Net
Once you have the Byte array you can save it as following
string directory = System.IO.Path.GetDirectoryName("D:\\sample\\Slide1.JPG");
string folderName = System.IO.Directory.CreateDirectory(directory).Name;
DataTable dt = new DataTable();
Byte[] bytes = (Byte[])dt.Rows[0]["Data"];
System.IO.File.WriteAllBytes(@"C:\files\mypdf.pdf", bytes);