Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Insert By file size

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2006-09-05 : 01:28:17
Dear Team,
I want to insert the file size and modified time in the two different columns of a table.Is there any stored procedures avaliable.I am using VB 6.0 as Front End Application.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-05 : 01:30:43
use your front end app to read the file size & modified time and assign to the variable

declare
@file_size int,
@modified_time datetime

insert into table (file_size, modified_time)
select @file_size, @modified_time



KH

Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2006-09-05 : 05:54:15
Is there any SQL stored procedure avalible for this like supply file name and insert the file_size automatically.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-05 : 06:50:20
Something like this, perhaps?
CREATE TABLE	#Files
(
Information VARCHAR(300)
)

INSERT #Files
(
Information
)
EXEC master..xp_cmdshell 'dir /4 /-c /tw %windir%\*.*'

DELETE
FROM #Files
WHERE LEFT(Information, 1) = ' '
OR Information IS NULL
OR SUBSTRING(Information, 22,5) = '<DIR>'

INSERT MyTable
(
FileName,
FileSize,
FileWritten
)
SELECT SUBSTRING(Information, 37, 80) FileName,
CONVERT(INT, SUBSTRING(Information, 26, 10)) FileSize,
CONVERT(DATETIME, LEFT(Information, 17)) FileWritten
FROM #Files

DROP TABLE #Files


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-09-05 : 11:03:55
see
http://www.nigelrivett.net/SQLTsql/ImportTextFiles.html

You can call the first sp with a filename if you wish.
You can also apss the file size and date to the second sp to be inserted.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -