June 9, 2006 at 1:48 pm
Is there any command on SQl that read the date from a file?
ex: file name = abc.txt and the date is 06/08/2006
wich command will read that date?? if any??
thanks
June 9, 2006 at 3:47 pm
Use this:
EXEC master.dbo.xp_getfiledetails '[Path\Filename]'
It returns
Alternate Name
Size
Creation Date
Creation Time
Last Written Date
Last Written Time
Last Accessed Date
Last Accessed Time
Attributes
Jason
-
June 12, 2006 at 6:03 am
thanks, it works
now I need to do this somehow
select @date = select creation date from (EXEC master.dbo.xp_getfiledetails '\\atlaback\D$\sql_backup\LPUSAS-WINDIAG\WINDIAG2\*.BAK')
this statment it's not working, any ideas?
thanks again
June 12, 2006 at 9:29 am
You need to put the results of xp_getfiledetails into a temp table and then set your variable to the creation date (see below)
DECLARE @dtDate DATETIME
IF EXISTS(Select * from tempdb.dbo.sysobjects where id = OBJECT_ID(N'tempdb.dbo.#tblResults'))
DROP TABLE #tblResults
CREATE TABLE #tblResults (vcAName varchar(8000),iSize INT, vcCreateDate VARCHAR(25),vcCreateTime VARCHAR(25),vclWriteDate VARCHAR(25),vcLWriteTime VARCHAR(25),vcLAccessDate VARCHAR(25),vcLAccessTime VARCHAR(25),iAttributes INT)
INSERT INTO #tblResults EXEC master.dbo.xp_getfiledetails '\\atlaback\D$\sql_backup\LPUSAS-WINDIAG\WINDIAG2\*.BAK'
SET @dtDate = (Select cast(vcCreateDate as Datetime) from #tblResults)
be aware that the use of *.BAK will return the filedetails only of the first .bak file foud in the path. If you need a different file than this you need to specify the file name.
Jason
-
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply