开发者

counting number of lines of a text file in a stored procedure

开发者 https://www.devze.com 2023-01-24 17:58 出处:网络
I need to open and count the number of lines in a text file using a stored 开发者_开发技巧procedure. The stored procedure should return a value whenever executed. Can you help me?In Sybase it is simpl

I need to open and count the number of lines in a text file using a stored 开发者_开发技巧procedure. The stored procedure should return a value whenever executed. Can you help me?


In Sybase it is simple.

EXEC @LineCount = xp_cmdshell(unix_command)

(Your DBA might have to fiddle around a tiny bit if they have not set the XP server up, but it comes on the CD, is fully documented, very easy (for a DBA), etc.)

The Unix command is of course word count, with the -line operator (indicating you want a count of lines):

santosh$ wc -l file_name

MS is identical, at least the last time I used it. But the issue there is, getting the line count on the MS-DOS side. If you have Cygwin or similar then use the Unix command.

0

精彩评论

暂无评论...
验证码 换一张
取 消