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.
| Author |
Topic |
|
nehj76
Starting Member
15 Posts |
Posted - 2007-08-23 : 14:23:54
|
| Hi there!I need help on how to count the number of lines in a text file..Pls. advisethanks in advance |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nehj76
Starting Member
15 Posts |
Posted - 2007-08-23 : 14:34:39
|
| Hi Brett,I need to open a text file and check if how many lines are there for ex.. file c:\test\test.txt has 8 records..in TSQL, how can i actually count the number of records that test.txt actually has?thanks.. |
 |
|
|
nehj76
Starting Member
15 Posts |
Posted - 2007-08-23 : 14:36:51
|
| c:\test\test.txt is terminated with a line-feed character |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-08-23 : 15:18:41
|
| http://www.fileviewer.com/"V is an all-purpose File Manager for Windows (95/98/Me/XP/NT4/2000/2003). Although V might look like another Windows Explorer replacement, its main strength is its file viewing capabilities. It excels at viewing files quickly - whether the files are 100 bytes or 100 gigabytes. Support for EBCDIC files (including common RECFM formats) make it ideal for those who work in a mainframe environment. "CODO ERGO SUM |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 15:41:46
|
Or open the file with OPENROWSET as SELECT COUNT(*) FROM OPENROWSET(....) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
nehj76
Starting Member
15 Posts |
Posted - 2007-08-23 : 15:42:10
|
| Hi Guys,I was able to find the solution:declare @testing varchar(255)drop table [dbo].[testfile]CREATE TABLE [dbo].[testfile] (line varchar(255) null);insert into [dbo].[testfile] EXEC master..xp_cmdshell 'find /c " " M:\ACE\Dataout\daily\si082307.txt'set @testing = (select top 1 right(line,2) from [dbo].[testfile] order by line desc)print @testingThanks |
 |
|
|
|
|
|