?
Solved

how to open text file by T-SQL script?

Posted on 2005-04-12
2
Medium Priority
?
420 Views
Last Modified: 2008-02-01
how to do the following thing by T-SQL script?
*****************************
open a text file, and count the number of specific character in the text.
*****************************
0
Comment
Question by:DataField
2 Comments
 
LVL 1

Accepted Solution

by:
InactiveX earned 2000 total points
ID: 13770891
Something like this will do the trick, depends how big your file is as well look at the size of the field holding the data
If its a lot of data you are better off reading in the by line add adding a record each time
then do your replace in the same way

You will need to drop the temp file after


CREATE PROCEDURE getmyFileSize(@myfile varchar(2000), @char2count varchar(1) )
AS
BEGIN
      --Temporary table for getting details
      CREATE TABLE #tmp (sName VARCHAR(20000))  
      --Gets the data from file to Temp table
      BULK INSERT #tmp
         FROM @file
         WITH (ROWTERMINATOR = '\n')
      --returns the number of replacements assumes your char is not £
      SELECT replace(@char2count,"£") as 'Charcount'
END
0
 

Author Comment

by:DataField
ID: 13777793
excellent idea!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question