Friday, March 23, 2012

Export and email query as a CSV

I would like to run a set of SQL statements stored in a table and email
the results as an attached CSV. This will be run as a procedure.
I also have to use an external mail server. I got an email
component,XPSMTP.DLL - SQL Server SMTP Mail XP, from
http://www.sqldev.net/xp/xpsmtp.htm#Installation
To date I have got the parts but not the whole working.
-I have sent emails through 2 different smtp servers.
-I can make the following SQL statement work and the file is correctly
created.
EXEC master..xp_cmdshell 'BCP "Select EmployeeCode,
CommencementDate from mydatabase..Appointment" queryout
c:\temp\csvexp21.csv -w -t"," -T -S '
output
(null)
Starting copy...
(null)
10 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 1
(null)
However the following procedure will run and send the emails but not
create the files. I have tested the SQL from the tables and the
statements run.
I am at a loss to know what to do now. If anyone can help I would
really appreciate it.
/* Procedure */
CREATE procedure pg_email_process
as
DECLARE email CURSOR FAST_FORWARD for
select query_sql, to_name, to_email, from_name, from_email, subject,
message, messagefile, server from pg_email_queries
--define variables
declare @.query_sql NVARCHAR(500)
declare @.to_name NVARCHAR(100)
declare @.to_email NVARCHAR(100)
declare @.from_name NVARCHAR(100)
declare @.from_email NVARCHAR(100)
declare @.subject NVARCHAR(100)
declare @.message NVARCHAR(4000)
declare @.messagefile NVARCHAR(255)
declare @.server NVARCHAR(50)
declare @.sql VARCHAR(255)
declare @.filename VARCHAR(255)
declare @.filepath VARCHAR(255)
declare @.rc int
--open the cursor
open email
FETCH NEXT FROM email
INTO
@.query_sql,@.to_name,@.to_email,@.from_name
,@.from_email,@.subject,@.message,@.mess
agefile,@.server
WHILE @.@.FETCH_STATUS=0
BEGIN
SELECT @.filename = (
select convert(varchar(10),getdate(),112)
+ '_'
+ replace(convert(varchar(15),getdate(),11
4),':','')
+ '.csv'
)
set @.filePATH = 'c:\Temp' + @.filename
SET @.sql = 'BCP "' + @.query_sql + '" queryout "' + @.filename + '" -w
-t"," -T -S'
EXEC master..xp_cmdshell @.sql, no_output
exec @.rc = master.dbo.xp_smtp_sendmail
@.FROM = @.from_email,
@.FROM_NAME = @.from_name,
@.TO = @.to_email,
@.CC = N'',
@.BCC = N'',
@.priority = N'HIGH',
@.subject = @.subject,
@.message = @.message,
@.type = N'text/html',
@.attachments= @.filename,
@.server = @.server
select RC = @.rc
FETCH NEXT FROM email
INTO
@.query_sql,@.to_name,@.to_email,@.from_name
,@.from_email,@.subject,@.message,@.mess
agefile,@.server
END
CLOSE email
DEALLOCATE email
/* Code to create table and some records for running queries */
if (not object_id('pg_email_queries') is null)
drop table pg_email_queries
go
create table pg_email_queries
(
query_sql NVARCHAR(500) NOT NULL,
to_name NVARCHAR(100) NULL,
to_email NVARCHAR(100) NOT NULL,
from_name NVARCHAR(100) NULL,
from_email NVARCHAR(100) NOT NULL,
subject NVARCHAR(100) NULL,
message NVARCHAR(4000) NULL,
messagefile NVARCHAR(255) NULL,
server NVARCHAR(50) NULL
)
go
insert into pg_email_queries
values ('Select EmployeeCode, WorkAreaCode, CommencementDate from
Appointment',
'gavin to',
'myemail@.email.address',
'gavin from',
'myemail@.email.address',
'Latest 10 Appointments',
'<html><body><h1>Appointments due</h1><p>Attached are the latest set
of appointments</p><pre>%data%</pre></body></html>',
'',
'smtp.utopia.co.nz'
)
go
insert into pg_email_queries
values ('Select EmployeeCode, WorkAreaCode, CommencementDate from
Appointment',
'gavin to',
'myemail@.email.address',
'gavin from',
'myemail@.email.address',
'Second Test - Latest 10 Appointments',
'<html><body><h1>Appointments due</h1><p>Attached are the latest set
of appointments</p><pre>%data%</pre></body></html>',
'',
'smtp.utopia.co.nz'
)
goWho is executing the stored procedure? You might want to check this:
http://msdn.microsoft.com/library/d.../>
sz_8sdm.asp
-oj
"celtic_kiwi" <gavin.jolly@.gmail.com> wrote in message
news:1107571605.571286.305350@.o13g2000cwo.googlegroups.com...
>I would like to run a set of SQL statements stored in a table and email
> the results as an attached CSV. This will be run as a procedure.
> I also have to use an external mail server. I got an email
> component,XPSMTP.DLL - SQL Server SMTP Mail XP, from
> http://www.sqldev.net/xp/xpsmtp.htm#Installation
> To date I have got the parts but not the whole working.
> -I have sent emails through 2 different smtp servers.
> -I can make the following SQL statement work and the file is correctly
> created.
> EXEC master..xp_cmdshell 'BCP "Select EmployeeCode,
> CommencementDate from mydatabase..Appointment" queryout
> c:\temp\csvexp21.csv -w -t"," -T -S '
> output
> (null)
> Starting copy...
> (null)
> 10 rows copied.
> Network packet size (bytes): 4096
> Clock Time (ms.): total 1
> (null)
> However the following procedure will run and send the emails but not
> create the files. I have tested the SQL from the tables and the
> statements run.
> I am at a loss to know what to do now. If anyone can help I would
> really appreciate it.
>
> /* Procedure */
> CREATE procedure pg_email_process
> as
> DECLARE email CURSOR FAST_FORWARD for
> select query_sql, to_name, to_email, from_name, from_email, subject,
> message, messagefile, server from pg_email_queries
> --define variables
> declare @.query_sql NVARCHAR(500)
> declare @.to_name NVARCHAR(100)
> declare @.to_email NVARCHAR(100)
> declare @.from_name NVARCHAR(100)
> declare @.from_email NVARCHAR(100)
> declare @.subject NVARCHAR(100)
> declare @.message NVARCHAR(4000)
> declare @.messagefile NVARCHAR(255)
> declare @.server NVARCHAR(50)
> declare @.sql VARCHAR(255)
> declare @.filename VARCHAR(255)
> declare @.filepath VARCHAR(255)
> declare @.rc int
> --open the cursor
> open email
>
> FETCH NEXT FROM email
> INTO
> @.query_sql,@.to_name,@.to_email,@.from_name
,@.from_email,@.subject,@.message,@.me
ssagefile,@.server
> WHILE @.@.FETCH_STATUS=0
> BEGIN
> SELECT @.filename = (
> select convert(varchar(10),getdate(),112)
> + '_'
> + replace(convert(varchar(15),getdate(),11
4),':','')
> + '.csv'
> )
> set @.filePATH = 'c:\Temp' + @.filename
> SET @.sql = 'BCP "' + @.query_sql + '" queryout "' + @.filename + '" -w
> -t"," -T -S'
> EXEC master..xp_cmdshell @.sql, no_output
>
> exec @.rc = master.dbo.xp_smtp_sendmail
> @.FROM = @.from_email,
> @.FROM_NAME = @.from_name,
> @.TO = @.to_email,
> @.CC = N'',
> @.BCC = N'',
> @.priority = N'HIGH',
> @.subject = @.subject,
> @.message = @.message,
> @.type = N'text/html',
> @.attachments= @.filename,
> @.server = @.server
> select RC = @.rc
> FETCH NEXT FROM email
> INTO
> @.query_sql,@.to_name,@.to_email,@.from_name
,@.from_email,@.subject,@.message,@.me
ssagefile,@.server
> END
> CLOSE email
> DEALLOCATE email
>
> /* Code to create table and some records for running queries */
>
> if (not object_id('pg_email_queries') is null)
> drop table pg_email_queries
> go
> create table pg_email_queries
> (
> query_sql NVARCHAR(500) NOT NULL,
> to_name NVARCHAR(100) NULL,
> to_email NVARCHAR(100) NOT NULL,
> from_name NVARCHAR(100) NULL,
> from_email NVARCHAR(100) NOT NULL,
> subject NVARCHAR(100) NULL,
> message NVARCHAR(4000) NULL,
> messagefile NVARCHAR(255) NULL,
> server NVARCHAR(50) NULL
> )
> go
>
> insert into pg_email_queries
> values ('Select EmployeeCode, WorkAreaCode, CommencementDate from
> Appointment',
> 'gavin to',
> 'myemail@.email.address',
> 'gavin from',
> 'myemail@.email.address',
> 'Latest 10 Appointments',
> '<html><body><h1>Appointments due</h1><p>Attached are the latest set
> of appointments</p><pre>%data%</pre></body></html>',
> '',
> 'smtp.utopia.co.nz'
> )
> go
>
> insert into pg_email_queries
> values ('Select EmployeeCode, WorkAreaCode, CommencementDate from
> Appointment',
> 'gavin to',
> 'myemail@.email.address',
> 'gavin from',
> 'myemail@.email.address',
> 'Second Test - Latest 10 Appointments',
> '<html><body><h1>Appointments due</h1><p>Attached are the latest set
> of appointments</p><pre>%data%</pre></body></html>',
> '',
> 'smtp.utopia.co.nz'
> )
> go
>|||I am a bit of a newbie to database admin.
I am using MSDE on my PC (XP SP1) with the account using NT
authentication.
I am logged into windows as admin.
I can run the email and bcp export.
I cannot run the procedure as Admin.
I am not sure what to do with the link you sent me.
Thanks for your reply, sorry I cannot help myself even with your help.
Gavin|||I did some more searching and ran a trace, for the fist time ever. Here
is the data in Tab separated format with quotes around values. 22 rows
11 columns.
I noticed the procedure was running as SYSTEM rather than ADMIN. Could
this be the cause?
EventClass TextData DatabaseID Transacti
onID NTUserName NTDomainName HostNam
e ApplicationName LoginName Success Inte
gerData
'11' 'exec
dbo. pg_email_process' '7' '(null)' 'admin' '
GAVINLAPTOP' 'GAVINLAPTOP' 'Adva
nced
Query Tool V6' 'GAVINLAPTOP\admin' '(null)' '(null)
'
'42' 'exec
dbo. pg_email_process' '7' '(null)' 'admin' '
GAVINLAPTOP' 'GAVINLAPTOP' 'Adva
nced
Query Tool V6' 'GAVINLAPTOP\admin' '(null)' '(null)
'
'14' '-- network protocol: LPC
set quoted_identifier on
set implicit_transactions off
set cursor_close_on_commit off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '1' '4096'
'12' ' set quoted_identifier off' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'11' 'declare @.P1 int
set @.P1=-1
exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
WorkAreaCode, CommencementDate from treetop..Appointment ', 1
select @.P1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'10' 'declare @.P1 int
set @.P1=1
exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
WorkAreaCode, CommencementDate from treetop..Appointment ', 1
select @.P1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'SELECT BCPCollationName(0x0904D00034, 167),
BCPCollationName(0x0904D00034, 167)' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'11' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'10' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'15' '(null)' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '1' '(null)'
'14' '-- network protocol: LPC
set quoted_identifier on
set implicit_transactions off
set cursor_close_on_commit off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '1' '4096'
'12' ' set quoted_identifier off' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'11' 'declare @.P1 int
set @.P1=-1
exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
WorkAreaCode, CommencementDate from treetop..Appointment ', 1
select @.P1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'10' 'declare @.P1 int
set @.P1=1
exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
WorkAreaCode, CommencementDate from treetop..Appointment ', 1
select @.P1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'SELECT BCPCollationName(0x0904D00034, 167),
BCPCollationName(0x0904D00034, 167)' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'11' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'10' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '(null)' '(null)'
'15' '(null)' '1' '(null)' 'SYSTEM' 'NT
AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
AUTHORITY\SYSTEM' '1' '(null)'
All help much appreciated. TIA
Gavin|||System account does have full access to the local machine. However, it does
not have a profile.
A few thing to check:
1. Is your Sqlserver service startup account an NT account. If it's started
by LocalSystem, Sqlserver will not have access to network resources. You can
use Service mgr or Enterprise mgr to check.
2. Use the link I posted in previous post to set your proxy account.
Basically, if the user executes the stored procedure is not a SQL admin,
he/she will be impersonating the proxy account to access the system
resources.
-oj
"celtic_kiwi" <gavin.jolly@.gmail.com> wrote in message
news:1107648291.339211.234390@.o13g2000cwo.googlegroups.com...
>I did some more searching and ran a trace, for the fist time ever. Here
> is the data in Tab separated format with quotes around values. 22 rows
> 11 columns.
> I noticed the procedure was running as SYSTEM rather than ADMIN. Could
> this be the cause?
> EventClass TextData DatabaseID TransactionID NTUserName NTDomainName
> HostName ApplicationName LoginName Success IntegerData
> '11' 'exec
> dbo.pg_email_process' '7' '(null)' 'admin' 'GAVINLAPTOP' 'GAVINLAPTOP'
> 'Advanced
> Query Tool V6' 'GAVINLAPTOP\admin' '(null)' '(null)'
> '42' 'exec
> dbo.pg_email_process' '7' '(null)' 'admin' 'GAVINLAPTOP' 'GAVINLAPTOP'
> 'Advanced
> Query Tool V6' 'GAVINLAPTOP\admin' '(null)' '(null)'
> '14' '-- network protocol: LPC
> set quoted_identifier on
> set implicit_transactions off
> set cursor_close_on_commit off
> set ansi_warnings on
> set ansi_padding on
> set ansi_nulls on
> set concat_null_yields_null on' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '1' '4096'
> '12' ' set quoted_identifier off' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '11' 'declare @.P1 int
> set @.P1=-1
> exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
> WorkAreaCode, CommencementDate from treetop..Appointment ', 1
> select @.P1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '10' 'declare @.P1 int
> set @.P1=1
> exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
> WorkAreaCode, CommencementDate from treetop..Appointment ', 1
> select @.P1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
> treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'SELECT BCPCollationName(0x0904D00034, 167),
> BCPCollationName(0x0904D00034, 167)' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
> treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '11' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '10' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '15' '(null)' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '1' '(null)'
> '14' '-- network protocol: LPC
> set quoted_identifier on
> set implicit_transactions off
> set cursor_close_on_commit off
> set ansi_warnings on
> set ansi_padding on
> set ansi_nulls on
> set concat_null_yields_null on' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '1' '4096'
> '12' ' set quoted_identifier off' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '11' 'declare @.P1 int
> set @.P1=-1
> exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
> WorkAreaCode, CommencementDate from treetop..Appointment ', 1
> select @.P1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '10' 'declare @.P1 int
> set @.P1=1
> exec sp_prepare @.P1 output, NULL, N'Select top 10 EmployeeCode,
> WorkAreaCode, CommencementDate from treetop..Appointment ', 1
> select @.P1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
> treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'SELECT BCPCollationName(0x0904D00034, 167),
> BCPCollationName(0x0904D00034, 167)' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '12' 'Select top 10 EmployeeCode, WorkAreaCode, CommencementDate from
> treetop..Appointment' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '11' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '10' 'exec sp_unprepare 1' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '(null)' '(null)'
> '15' '(null)' '1' '(null)' 'SYSTEM' 'NT
> AUTHORITY' 'GAVINLAPTOP' 'Microsoft SQL Server' 'NT
> AUTHORITY\SYSTEM' '1' '(null)'
> All help much appreciated. TIA
> Gavin
>|||Gavin,
This is exactly what Gadami does.
With Gadami you can run a SQL query against SQL Server and email the results
in a CSV file.
Give the product a try. Download version 1.52 from http://www.kripsoft.com.
-Krip|||Krip wrote:
> Gavin,
> This is exactly what Gadami does.
> With Gadami you can run a SQL query against SQL Server and email the resul
ts
> in a CSV file.
> Give the product a try. Download version 1.52 from http://www.kripsoft.com.[/colo
r]
But first, read BOL's article: "Using SQL Mail Stored Procedures"
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

No comments:

Post a Comment