bustercoder
Programmer
- Mar 13, 2007
- 96
Hello,
I've done everything I can think of to try and make this work the way Microsoft says it's supposed to, maybe I'm just overlooking some mundane detail:
The following makes no difference:
- used the object owner name and naming in general
- checked permissions on all the objects involved
- exec the sp on its own, it fires ok
- the text file is created ok
- the data is written to the auditlog table ok
- tested trigger with stored proc and with only selecting from a table (code commented below), made no difference, same error
/*** Here is my data table ***/
create table test1 (
Field1 char(5),
Field2 char(5),
Field3 char(5)
)
/*** Here is my static audit table ***/
create table auditlog (
FieldId int identity,
Field1 char(5),
Field2 char(5),
Field3 char(5)
)
/*** I use this procedure to grab the data out ***/
create procedure testsp1 @FieldId int as
set nocount on
select * from auditlog WITH (NOLOCK) where Fieldid = @FieldId
go
/*** Here is my trigger ***/
alter trigger testtr1 on test1 for insert as
set nocount on
declare @msg varchar(255), @IdentValue varchar(8)
insert into AuditLog (Field1,Field2,Field3)
select * from inserted
select @IdentValue = convert(varchar,@@identity)
--select @msg = 'isql -Q"exec testsp1 '+@IdentValue+'" -E -w255 -oc:\temp\audit'+@IdentValue+'.txt'
select @msg = 'isql -Q"select * from auditlog " -E -w255 -oc:\temp\audit'+@IdentValue+'.txt'
exec master..xp_cmdshell @msg
go
/*** Here is my test data ***/
insert into test1 values ('123','123','123')
/*** Here is my error: ***/
Msg 208, Level 16, State 1, Server DRDEV2, Line 1
Invalid object name 'auditlog'.
Any help would be so GREATLY appreciated.
Thanks,
Buster
I've done everything I can think of to try and make this work the way Microsoft says it's supposed to, maybe I'm just overlooking some mundane detail:
The following makes no difference:
- used the object owner name and naming in general
- checked permissions on all the objects involved
- exec the sp on its own, it fires ok
- the text file is created ok
- the data is written to the auditlog table ok
- tested trigger with stored proc and with only selecting from a table (code commented below), made no difference, same error
/*** Here is my data table ***/
create table test1 (
Field1 char(5),
Field2 char(5),
Field3 char(5)
)
/*** Here is my static audit table ***/
create table auditlog (
FieldId int identity,
Field1 char(5),
Field2 char(5),
Field3 char(5)
)
/*** I use this procedure to grab the data out ***/
create procedure testsp1 @FieldId int as
set nocount on
select * from auditlog WITH (NOLOCK) where Fieldid = @FieldId
go
/*** Here is my trigger ***/
alter trigger testtr1 on test1 for insert as
set nocount on
declare @msg varchar(255), @IdentValue varchar(8)
insert into AuditLog (Field1,Field2,Field3)
select * from inserted
select @IdentValue = convert(varchar,@@identity)
--select @msg = 'isql -Q"exec testsp1 '+@IdentValue+'" -E -w255 -oc:\temp\audit'+@IdentValue+'.txt'
select @msg = 'isql -Q"select * from auditlog " -E -w255 -oc:\temp\audit'+@IdentValue+'.txt'
exec master..xp_cmdshell @msg
go
/*** Here is my test data ***/
insert into test1 values ('123','123','123')
/*** Here is my error: ***/
Msg 208, Level 16, State 1, Server DRDEV2, Line 1
Invalid object name 'auditlog'.
Any help would be so GREATLY appreciated.
Thanks,
Buster