Reading A Directory

Feb 28, 2007

I do a lot of file processing and I usually run a little script I copy
and paste to read directory information to see if a new file it there
and then process the file if it is. So, I decided to wise up and make
a stored procedure to automate a lot of that.

The pivotal step in this is that i run a command that looks like:

CREATE TABLE #DIR (FileName varchar(100))

DECLARE @Cmd varchar(1050)
SET@Cmd = 'DIR "' + @Path + CASE WHEN RIGHT(@Path, 1) = '' THEN ''
ELSE '' END + @WildCard + '"'

INSERT INTO #DIR
EXEC master..xp_CmdShell @Cmd

When I run the stored procedure I get back the files and folders in
there that match the wildcard and all is good!!!!

....Until I try to put that information into a table while calling that
stored procedure:

CREATE TABLE #Files (
Path varchar(100),
FileName varchar(100),
PathAndFileName varchar(150),
FileDateTime SmallDateTime,
FileLength int,
FileType Varchar(10))

INSERT INTO #Files
EXEC sp_GetFileNames @Path = '\isoft2ftpLegacyBilling', @Wildcard
= '*.txt'

When I run this I get:

Server: Msg 8164, Level 16, State 1, Procedure sp_GetFileNames, Line
53
An INSERT EXEC statement cannot be nested.

Because I use an INSERT EXEC to with the results from the @Cmd.

Anybody have any ideas how I can get that information into a table?

I did try to just copy the data to c: empdir.txt and then bulk
import it in. But when it runs the @Cmd to create the file it comes
back with a NULL value and my stored procedure returns two sets of
values... which I can't do.

So, I would appreciate anybody who can help.

Thanks!

-utah

View 4 Replies


ADVERTISEMENT

Using Provider For Microsoft Directory Services For Querying Active Directory

Apr 6, 2007

Has anyone used this successfully from an OLEDB source component, or even from the Execute SQL Task? I've seen some examples of using a script component, but nothing that uses it through a connection manager.

View 6 Replies View Related

For Each Directory

Jun 5, 2007

How can I modify the for each loop to go through all the folders under parent folder?



ParentFolder

SubFolder1

SubFolder2

SubFolder3





View 7 Replies View Related

Reading An Excel Doc

Jul 16, 2007

hi guys, Can anyone advise me how how to read an excel doc i have stored locally? I need to be able to start the read from say row number 6 and finish the read once i get to a row that contains a pre-determined  word signifying the end of processing. I intend to store the parsed data in an array that will be used as the data source for a gridview or repeater object on another asp page. I'm using ASP.net 2.0 and C# by the way. thanks in advance for any help!!! 

View 12 Replies View Related

DataReader Not Reading

Jan 13, 2004

Why won't this dataReader read?

Dim objCon2 As New SqlConnection()
objCon2.ConnectionString = "a standard connection string"
objCon2.Open()

Dim objCommand As SqlCommand
objCommand = New SqlCommand(strSQL, objCon2)
Dim objReader As SqlDataReader
objReader = objCommand.ExecuteReader()

Label1.Text = objReader("email")

strSQL is a select command which I've checked (using SQL Query analyzer) does return data. I know the connection string is valid (and I presume if it wasn't that it'd fail on objCon2.open, which it doesn't).

So why oh why do I get this error on the last line (and yes, there is an "email" field in the contents of the reader)

System.InvalidOperationException: Invalid attempt to read when no data is present.

View 1 Replies View Related

Help With Reading Database.

Jun 29, 2005

I have this code that I hacked together from someone else's example.  I kind of understand how it works.  I just don't know if it will and i am not in a location right now to check.  I was wondering if I did this correctly first, second how can it improve and should i do something different.  Basically i just want to check the password in a database. I am passing the username and password to this function from another functioprivate bool authUser(string UserName, string Password){ string connectionString = ConfigurationSettings.AppSettings["DBConnectionString"];  SqlConnection DBConnection = new SqlConnection(connectionString);  bool result = false;  DBConnection.open() SqlCommand checkCommand = new SqlCommand("SELECT password FROM Users WHERE userName='" + Password + "', DBConnection) SqlDataReader checkDataReader = checkCommand.ExecuteReader();
 if(checkDataReader.GetString(0) == Password) {  result = true; } else {  result = false; } checkDataReader.Close(); DBConnection.Close();
 return result;}Thank you Buddy Lindsey

View 6 Replies View Related

Reading Transaction Log

May 30, 2001

Does anyone know how to read transaction log besides trace and profiler. The current situation is some one in our org. deleted an item and I'm trying to find out who and when.

View 2 Replies View Related

Reading Log File

Feb 9, 2000

I have some records that have been deleted. I need to find out who did it and to do that I need to read the logs. Are there any utilities that will allow me to read login 7.0? How about 6.5?

Chris

View 2 Replies View Related

Reading The Transaction Log In SQL 7.0

Dec 22, 1999

Here is I think an interesting question
is there a way to read or access the transaction log of a
database in SQL server 7.0

Hoping someone has a solution :-)

View 5 Replies View Related

Reading The Transaction Log

Nov 2, 1999

We are having continual problems with our transaction log filling up on one of our major applications.
Does anyone know of a way or tool to read the transaction log? We want to determine what is causing this problem.

Thanks

View 3 Replies View Related

Reading The Transaction Log

Jul 12, 1999

Is there a way, in SQL 7.0 to print out or view what's in the Transaction Log? In 6.5 you could view the table syslogs, but I don't see any documentation anywhere on how to do this in 7.0.

View 1 Replies View Related

Reading Xml In A Sql Table

Apr 8, 2005

I receive in a table a field which is an xml string
like below

<NewOrder><SiteID>CJC</SiteID><patID>458887</patID><LName>Cronin</LName><FName>tim</FName><EntryID>{7B1A4946-CEC8-4F23-AE89-5C70A6A0F9B2}</NewOrder>

Is there a way read this field with a select statement? I need to strip out the entryid value in a trigger

View 4 Replies View Related

Reading SQL 6.5 Databases

Aug 23, 2001

I received a SQL Server 6.5 database (.dat file) on a removeable drive. I'm currently running 7.0. Is there any way to read/import/link to this data without installing 6.5. And if I have to install 6.5 how do I get the system to see the database?

View 1 Replies View Related

Reading MS-SQL Transaction Log

May 24, 2002

Hello people;


Somebody knows some utility where I can read the Transaction Log Sql 2000 ?

Thanks;


Navlig®

View 1 Replies View Related

Reading A Ini File In DTS

Jun 10, 2002

Hi

How can I read an ini file entry and pass this parameter to a stored procedure which will be run in a DTS Package?


Thanks for the input

mipo

View 2 Replies View Related

Reading DTS Packages

Sep 19, 2001

Anyone know a way to read DTS packages? I have inherited a DTS package, saved in SQL, and am trying to find a way to read the steps without having to view every single step through the GUI.

Thanks in advance.

View 3 Replies View Related

Reading ClientProcessID

Sep 1, 2006

Hi,

I need to know that how can we read ClientProcessID (älso use used in SQL Profiler).

Regards,
Shabber.

View 2 Replies View Related

Reading Results Into .NET

May 20, 2008

Hi. I want to write a function to retrieve all records from a "Parts" table so that I can read these records in .NET.

SqlDataReader reader = sqlCmd.ExecuteReader()

while( reader.Read() )
{
int x = reader["id"];
string partName = reader["name"];

// Do stuff with data here //
}


My question: How should the function be written?

Should I create a PROCEDURE and just call a SELECT statement?

CREATE PROCEDURE getPartsList()
AS
SELECT part_id as 'id', part_name as 'name' FROM parts


Or should I create a FUNCTION that returns a TABLE? If so, is this the correct syntax?

CREATE FUNCTION getPartsList()
RETURNS TABLE
AS
RETURN (SELECT part_id as 'id', part_name as 'name' FROM parts)


Thanks for reading

View 3 Replies View Related

Reading XML Element

Jun 9, 2014

The requirement is to read XML element from database column.The column looks like

<ClMetadataDataContract xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cch.com/pfx.net/psi/">
<EntityType>1</EntityType>
<NameLine1>David Jones</NameLine1>

[code]....

I have also tries OPENXML but no luck

View 2 Replies View Related

Reading Log File

Jun 22, 2008

How do I view the SQL 2005 transaction log file(.ldf)?

Is there a built-in utility?

Thank you

View 3 Replies View Related

Reading A File

Jun 24, 2008

I am storing one text file on the server.This text file contains some mobile numbers.The file look like
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
etc

Here I need to read this text file row by row mobile number and then insert these mobile numbers into a table by using sql procedure or sql trigger or any other method or coding. Is it is possible or not?
If so then anybody can help me!

regards
Shaji

View 4 Replies View Related

Reading ID From XML File???

Jul 13, 2006

Hello friends...

We have sql server 2000 and i need to read one perticular xml and from that i want ID field stored in one table...is it possible by query analyzer to read xml and stored ID in table...I have only path of that xml file...



like



select ID from ("D:XMLFolder*.xml)



that i want

View 2 Replies View Related

SP Is Not Reading The Table Name?

Aug 23, 2006

-- drop proc SP_Trio_Popul_Stg_Tbls1
CREATE PROC [dbo].[SP_Trio_Popul_Stg_Tbls1] @tableName varchar(20) AS
-- alter PROC [dbo].[SP_Trio_Popul_Stg_Tbls1] @tableName varchar(20) AS


declare @sql varchar (20)

set @sql = 'INSERT INTO dbo.Name_Pharse_Stg_Tbl1 (nm_last)
SELECT nm_name FROM dbo.' + quotename(@tableName)

print @sql
exec (@sql)

----------------------------------------------------------------------
exec SP_Trio_Popul_Stg_Tbls1 '00485'
----------------------------------------------------------------------
INSERT INTO dbo.Name
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'Name'.


im trying to run this SP but im getting an error. Can you help me to fix it?

-------------------------
gongxia649
-------------------------

View 20 Replies View Related

Reading From A Xl Sheet

Jul 17, 2007

Hi All,

I would like to know if i can read data from xl sheet using a stored procedure?

Thanks in advance

vishu

View 17 Replies View Related

Recommend Some Reading

Jul 25, 2007

Hi,
I've been a developer for 20 some years, but never learned the design steps of a complex database. Can you give me a book or 2 to bring me up to speed with the latest database design and data modeling techniques?

thanks.....

View 3 Replies View Related

Reading Transaction Log.

Jul 20, 2005

Hi,How can i read information in Transaction Log in SQL Server 2000?Thanks

View 1 Replies View Related

Reading SQL Data

Jul 6, 2005

I posted this in the Windows Forms Data Binding section, and they directed me to the .Net data section.  I posted it there and waited a week with no replies.  I'm hoping someone here can at least give me an idea of what the problem might be.

View 1 Replies View Related

Reading In An XML File From A URL

Oct 17, 2006

Hi

I have a problem with SSIS in that I need to read an XML file in from a URL,which brings me back the below XML. What I need to be able to do is essentially create a single record, including the nested XML <image> into the same record. This information then needs to be entered into a database table.

What I found is that if I use a data flow component, and have an XML source pointing to this URL, it essentially creates a different output for every level of nesting. This causes me serious issues because I would then have to somehow get to the information in the <image> tag, and then get everything below that, etc, to be able to get the images related to each <stock> record. This is a pain.

I also looked at using an XML task, where I could use an XSLT to transform to the required output, however, I can't point this XML task to a URL to retrieve the XML.

If anyone has any ideas I would greatly appreciate it

Thanks

Darrell



XML Format

------------------

<feed date="2006-10-17 17:08:46">

<usedstock>

<stock id="SFU22991">

<make>Peugeot</make>

<model>206</model>

<description>Peugeot 206 1.4 X-Line, 5 door Hatchback Tiptronic Auto 4Spd</description>

<hotline>08451553610</hotline>

<spec>Air Conditioning, Power Steering, Central Locking, Electric Windows, Alloy Wheels, CD Player</spec>

<deepurl>http://www.regvardy.com/used_car/dseller/SFU22991</deepurl>

<search>http://www.regvardy.com/used_cars/dseller/Peugeot/206</search>

<regdate>2005-01-27</regdate>

<colour>Blue</colour>

<price>7495</price>

<stocktype>USED</stocktype>

<category>Small</category>

<transmission>Tiptronic Auto 4Spd</transmission>

<bodystyle>Hatchback</bodystyle>

<fueltype>Petrol</fueltype>

<type>NCV</type>

<doors>5</doors>

<engine>PE0BC</engine>

<capcode>PE2614SED5HPIA</capcode>

<capid>26440</capid>

<image>

<urls>

<url>http://www.regvardy.com/imagedata/vehicles/g/pj54lyg_1.jpg</url>

<url>http://www.regvardy.com/imagedata/vehicles/g/pj54lyg_2.jpg</url>

<url>http://www.regvardy.com/imagedata/vehicles/g/pj54lyg_3.jpg</url>

</urls>

<libraryimage/>

</image>

</stock>

</usedstock>

</feed>

View 4 Replies View Related

How To Reading Clusters ?

Sep 20, 2006

Hi,

For our trainign data clustering models show the maximum accuracy.

We want to preset the results to our client. In order to do that we want to present what are the properties of each cluster.

For example for my predictable attribute if Cluster 9 is showing maximum population then I want to show what conditions of attributes make cluster 9 .

What is the way of doing this ?

Thanks,

Vkas

View 3 Replies View Related

ASP.NET: Reading A CSV File With C#

Jan 22, 2008

I am trying to read from a datasource that is a CSV file using C#, but for some reason I keep getting an error that says:

System.Exception: System.Data.OleDb.OleDbException: Syntax error in FROM clause.

My code looks like this:


String sql = " SELECT IDnumber FROM report.csv WHERE username = @Username ";



ArrayList parameters = new ArrayList();

parameters.Add(new OleDbParameter("@Username", Username));

DataTable dt = OleDbUtility.getDataTable(sql, parameters, OleDbUtility.GetCNetIDConnectionString());


It worked with an Excel file, so any ideas on this one?
It seems like the connection string is fine...

View 6 Replies View Related

Need Some Reading Material.

Jun 27, 2006

Hi

I was searching some books about SQL but all that i found was "Big books", i mean, i found books about all SQL Server and i just need to know a few things.

I'll need to make queries to a DB and make excel or acces reports based on the query result.

Well, thanks in advance

View 1 Replies View Related

Reading Messages With ADO .Net C#

Jul 3, 2007

Hello,



I am trying to figure out how to properly read a single message(poll) at a time from ADO .Net in c# 2005.



I am assuming i need to write a sproc that does a receive, but I wanted to validate if there were already any examples of this already?



I have been reading quite alot but don't see this exactly as an example anywhere and it is probably easier then my brain is allowing it to be.



If you have an example or would help me i would appreciate it. I am "hoping" for more then just "write a sproc and call it" as I believe this is accurate but am hoping for more info.



Happy to read, happy to research, but I am atm, lost for where to go next. I am going to start doing some plain testing, but appreciate any help.



Thanks,



-Mike

View 1 Replies View Related

Reading A File Name That Changes

Mar 13, 2007

Brand new to SSIS so bear with me, if something is obvious.

I want to be able to read a file from a certain directory. But the file name changes every day. So today its File20061203 tomorrow File20061304 or the next day it could be FileNB4434. The format in the file will always be the same though. I just want for a user to be able to drop a file in a directory and the package pick it up once a day.

Would I have to to create a script task or could I use a variable. I have been trying to use the variable but have not been able to get them to work. This calls for only looking for 1 text file in a folder but any additional links that show some good variable examples would be appreciated. One where only part of the variable changes File(Variable)Division.txt

Thanks in advance

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved