SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Insert By file size
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

danasegarane76
Posting Yak Master

India
240 Posts

Posted - 09/05/2006 :  01:28:17  Show Profile  Send danasegarane76 an ICQ Message
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)

Singapore
17681 Posts

Posted - 09/05/2006 :  01:30:43  Show Profile
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

India
240 Posts

Posted - 09/05/2006 :  05:54:15  Show Profile  Send danasegarane76 an ICQ Message
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

Sweden
30282 Posts

Posted - 09/05/2006 :  06:50:20  Show Profile  Visit SwePeso's Homepage
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

United Kingdom
12543 Posts

Posted - 09/05/2006 :  11:03:55  Show Profile  Visit nr's Homepage
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
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000