473,666 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

acess I/O File

Is it possible to access a file (for example, to write in a text file)
with transact-sql?.
I've create a stored procedure and I'd like to write in a log file
some traces depends on the result of the statements executed in this
stored procedure.
Thanks
Jul 20 '05 #1
1 3425
Here's one method:

ALTER PROC WriteToLog
@Message varchar(100)
AS
DECLARE @Command varchar(255)
BEGIN TRAN
-- ensure only one process writes to the log at a time
EXEC sp_getapplock
@Resource = 'MyLog.txt',
@lockmode = 'Exclusive'
SET @Command = 'ECHO ' +
@Message +
' >>"C:\MyLog.txt "'
EXEC master..xp_cmds hell @Command, NO_OUTPUT
EXEC sp_releaseapplo ck @Resource = 'MyLog.txt'
COMMIT
GO

EXEC WriteToLog 'Test message'

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Bego?a" <be**********@y ahoo.es> wrote in message
news:c0******** *************** ***@posting.goo gle.com...
Is it possible to access a file (for example, to write in a text file)
with transact-sql?.
I've create a stored procedure and I'd like to write in a log file
some traces depends on the result of the statements executed in this
stored procedure.
Thanks

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2681
by: Paul Close | last post by:
Hi Everyone, The following code runs in less than one second when used in an ASP page but when used in Session_onStart() in global.asa, the first page in a new session is delayed by more than thirty seconds. The code seems to work - its just slooow. Why is this so and how do I fix it? Dim cnComDoc Set cnComDoc = Server.CreateObject("ADODB.Connection") cnComDoc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
1
3026
by: Suresh | last post by:
Hi, Iam trying to develop a client in C# on .NET, that would acess a webservice written in Java.I dont know anything about what kind of WSDL would be required, how to set the web references programtically , dynamically during execution to pick a specified webservice( VS.NET provides a way to add the web refernce by right clicking on refernces icon, but this way is static)Is it possible to do so? Pleas help.
1
1205
by: Fabiano | last post by:
Please, i created a webpage that let's user upload a file to server. At my codebehind i need to save this file into a directory of another server (webfarm). The olny problem is that only some users can acess this directory. How can i do to send my credentials, this way be able to save at the directory? Tks in adv.
1
2203
by: Luis Esteban Valencia | last post by:
Hello. I got an error on my program. the code is very simple private void btnsubmit_Click(object sender, System.EventArgs e) { string requestLocation = "http://localhost:90/HTTPSender/BTSHTTPReceive.dll";
0
1511
by: Pk | last post by:
Hi, I want to download and upload the data from acess database into excel file or from excel to database. So how can i use "Excel.Application" to do this type of job. So please help me soon. Thanks Pk
3
6001
by: hbarnett | last post by:
I am in process of converting Access 97 databases to Access 2003. Some of the Access 97 databases export data to a text file with a non standard file extension, such as "ext" or "NAL". When I try to run the export in the converted Access 2003 database, I get the error "Cannot update: Database or object is read-only." It seems that the real problem is that I can only export a text file if I use either "txt", "csv", "tab", or "asc" as...
6
1762
by: santhosh83 | last post by:
i wt a command that can use to acess a line from a file in unix
1
4470
by: PK Pradeep | last post by:
Iam a fresher to the MS Acess world. Question is How to reduce the MDB file Size. I maintain a Access Data base where there are 5 Tables with each table containing 60, 000+ lines. If I delete the data by just blocking and delete from each table will my MDB size of the file will get reduced.
1
1903
by: lokeshreddy16 | last post by:
'this is my code plz guys help how to save data from vb 2005 and other this that i am able to view the data from acess but i am not able save to acess i dont whether my code for save is correct of not ( iam using vb2005 as front end and MS acess as by back end) Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the...
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.