Hello!
I am trying to capture all the infromation that DOS dir command
generates and stores it into a table called #DirectoryInfo. See below:
create table #DirectoryInfo (
dir varchar(255),
date datetime NULL,
size int,
name varchar(255),
type char(9))
insert #DirectoryInfo exec xp_cmdshell 'dir c:\MyDir\File1.txt'
I am getting this error message:
Server: Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 11
Insert Error: Column name or number of supplied values does not match
table definition.
what columns I am missing here? or am I am defining more columns than
expected? Thanks for your help.
This is what I get when I do a DIR command for c:\file1.txt
Volume in drive C is Dell Server
Volume Serial Number is XXXX-YYY
NULL
Directory of c:\MyDir
NULL
10/18/2005 10:05a 4 File1.txt
1 File(s) 4 bytes
0 Dir(s) 10,569,293,824 bytes free
Any help would be appreciated! Thanks!
*** Sent via Developersdex http://www.examnotes.net ***xp_cmdshell returns data in a single nvarchar(255) column. (see BOL
entry for more details)
Test Test wrote:
>Hello!
>I am trying to capture all the infromation that DOS dir command
>generates and stores it into a table called #DirectoryInfo. See below:
>create table #DirectoryInfo (
>dir varchar(255),
>date datetime NULL,
>size int,
>name varchar(255),
>type char(9))
>insert #DirectoryInfo exec xp_cmdshell 'dir c:\MyDir\File1.txt'
>I am getting this error message:
>Server: Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 11
>Insert Error: Column name or number of supplied values does not match
>table definition.
>what columns I am missing here? or am I am defining more columns than
>expected? Thanks for your help.
>This is what I get when I do a DIR command for c:\file1.txt
>
> Volume in drive C is Dell Server
> Volume Serial Number is XXXX-YYY
>NULL
> Directory of c:\MyDir
>NULL
>10/18/2005 10:05a 4 File1.txt
> 1 File(s) 4 bytes
> 0 Dir(s) 10,569,293,824 bytes free
>
>Any help would be appreciated! Thanks!
>
>*** Sent via Developersdex http://www.examnotes.net ***
>|||Try:
CREATE TABLE DIR
(DIRCOL NVARCHAR(255))
GO
INSERT DIR
EXEC MASTER..XP_CMDSHELL 'DIR C:'
GO
SELECT DIRCOL FROM DIR
HTH
Jerry
"Test Test" <farooqhs_2000@.yahoo.com> wrote in message
news:O7yrk1O1FHA.3256@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I am trying to capture all the infromation that DOS dir command
> generates and stores it into a table called #DirectoryInfo. See below:
> create table #DirectoryInfo (
> dir varchar(255),
> date datetime NULL,
> size int,
> name varchar(255),
> type char(9))
> insert #DirectoryInfo exec xp_cmdshell 'dir c:\MyDir\File1.txt'
> I am getting this error message:
> Server: Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 11
> Insert Error: Column name or number of supplied values does not match
> table definition.
> what columns I am missing here? or am I am defining more columns than
> expected? Thanks for your help.
> This is what I get when I do a DIR command for c:\file1.txt
>
> Volume in drive C is Dell Server
> Volume Serial Number is XXXX-YYY
> NULL
> Directory of c:\MyDir
> NULL
> 10/18/2005 10:05a 4 File1.txt
> 1 File(s) 4 bytes
> 0 Dir(s) 10,569,293,824 bytes free
>
> Any help would be appreciated! Thanks!
>
> *** Sent via Developersdex http://www.examnotes.net ***|||Thanks Jerry but I was hoping to store information (filename, extension,
size, datetime) in separte columns. What I need is FileName and FileSize
information. How do I get it? Should I extract it from DIRCOL from DIR
table? How?
*** Sent via Developersdex http://www.examnotes.net ***|||You could probably grab some of that information by using the undocumented
extended stored procedures in SQL Server however I'd probably use some other
method i.e., VBScript -->WSH --> SQL Table.
HTH
Jerry
"Test Test" <farooqhs_2000@.yahoo.com> wrote in message
news:%23zALTUP1FHA.3504@.TK2MSFTNGP10.phx.gbl...
> Thanks Jerry but I was hoping to store information (filename, extension,
> size, datetime) in separte columns. What I need is FileName and FileSize
> information. How do I get it? Should I extract it from DIRCOL from DIR
> table? How?
>
>
>
> *** Sent via Developersdex http://www.examnotes.net ***|||There is an example in this article that does almost exactly what you
are asking, I think:
http://users.drew.edu/skass/sql/TextDriver.htm
Steve Kass
Drew University
Test Test wrote:
>Hello!
>I am trying to capture all the infromation that DOS dir command
>generates and stores it into a table called #DirectoryInfo. See below:
>create table #DirectoryInfo (
>dir varchar(255),
>date datetime NULL,
>size int,
>name varchar(255),
>type char(9))
>insert #DirectoryInfo exec xp_cmdshell 'dir c:\MyDir\File1.txt'
>I am getting this error message:
>Server: Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 11
>Insert Error: Column name or number of supplied values does not match
>table definition.
>what columns I am missing here? or am I am defining more columns than
>expected? Thanks for your help.
>This is what I get when I do a DIR command for c:\file1.txt
>
> Volume in drive C is Dell Server
> Volume Serial Number is XXXX-YYY
>NULL
> Directory of c:\MyDir
>NULL
>10/18/2005 10:05a 4 File1.txt
> 1 File(s) 4 bytes
> 0 Dir(s) 10,569,293,824 bytes free
>
>Any help would be appreciated! Thanks!
>
>*** Sent via Developersdex http://www.examnotes.net ***
>
Friday, March 9, 2012
DOS dir command info in a table?
Labels:
belowcreate,
capture,
command,
commandgenerates,
database,
dir,
directoryinfo,
dos,
helloi,
infromation,
microsoft,
mysql,
oracle,
server,
sql,
stores,
table
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment