Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Error = [Microsoft][SQL Native Client][SQL Server]Invalid object name 'dbo.auditrec' Expand / Collapse
Author
Message
Posted Tuesday, July 20, 2010 2:05 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 2:41 AM
Points: 8, Visits: 26
1> 2> 1> 2> 3> 1> 2> 3> 4> 5> 6> 1> 2> output



------------------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------
NULL




(1 row affected)
1> 2> output



------------------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------
SQLState = S0002, NativeError = 208



Error = [Microsoft][SQL Native Client][SQL Server]Invalid object name 'dbo.auditrec'.


SQLState = 37000, NativeError = 8180



Error = [Microsoft][SQL Native Client][SQL Server]Statement(s) could not be prepared.


NULL




(5 rows affected)
1>


I get error message after run this sql across network as sql script below.

use DM_testDMS03_docbase
go
IF OBJECT_ID ('auditrec', 'view') IS NOT NULL DROP VIEW auditrec
go
create view auditrec as
select u.test_pol_no,u.test_box_id,u.object_name,u.event_name,u.user_name,u.event_description,
u.time_stamp from
(select dbo.test_supertype_sp.test_pol_no, dbo.test_supertype_sp.test_box_id, dbo.test_supertype_sp.object_name,
dbo.dm_audittrail_sp.event_name, dbo.dm_audittrail_sp.user_name, dbo.dm_audittrail_sp.event_description, dbo.dm_audittrail_sp.time_stamp
FROM dbo.dm_audittrail_sp INNER JOIN dbo.test_supertype_sp ON dbo.dm_audittrail_sp.chronicle_id = dbo.test_supertype_sp.r_object_id)u
go
exec master..xp_cmdshell 'IF EXIST D:\AuditExport\Report\policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt DEL D:\AuditExport\Report\policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt'
go
exec master..xp_cmdshell 'bcp "select * from dbo.auditrec order by test_pol_no desc" queryout "D:\AuditExport\Report\temp_policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt" -c -T -t ";"'
go

Please advice me!
Post #955345
Posted Tuesday, July 20, 2010 3:14 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:41 AM
Points: 3,930, Visits: 5,119
Try creating the view with the schema name
create view dbo.auditrec as 



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #955386
Posted Tuesday, July 20, 2010 3:32 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 2:41 AM
Points: 8, Visits: 26
Thanks for your reply.

I debug step by step and then i found as below.
1. use DM_SCNYLDMS03_docbase ==> pass
2. IF OBJECT_ID ('auditrec', 'view') IS NOT NULL DROP VIEW auditrec ==> pass
3. create view dbo.auditrec as
select u.scnyl_pol_no,u.scnyl_box_id,u.object_name,u.event_name,u.user_name,
u.event_description,u.time_stamp from
(select dbo.scnyl_supertype_sp.scnyl_pol_no, dbo.scnyl_supertype_sp.scnyl_box_id, dbo.scnyl_supertype_sp.object_name,
dbo.dm_audittrail_sp.event_name, dbo.dm_audittrail_sp.user_name, dbo.dm_audittrail_sp.event_description, dbo.dm_audittrail_sp.time_stamp
FROM dbo.dm_audittrail_sp INNER JOIN dbo.scnyl_supertype_sp ON
dbo.dm_audittrail_sp.chronicle_id = dbo.scnyl_supertype_sp.r_object_id)u
==> pass
4. exec master..xp_cmdshell 'IF EXIST D:\AuditExport\Report\policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt DEL D:\AuditExport\Report\policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt'
==> pass
5. exec master..xp_cmdshell 'bcp "select * from dbo.auditrec order by scnyl_pol_no desc" queryout "D:\AuditExport\Report\temp_policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt" -U scnyl\Administrator -P Passwords1 -S DISERVE-DB-01 -c -T -t ";"'
==> found the error
Error = [Microsoft][SQL Native Client][SQL Server]Invalid object name 'dbo.auditrec'.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][SQL Native Client][SQL Server]Statement(s) could not be prepared.


I already config at DISERVE-DB-01 (it's database server and the same instance name) as
1. open DB Engine remote connections to be "using TCP/IP and name pipes"

How can i do anymore????? Many thanks!!!


Post #955391
Posted Tuesday, July 20, 2010 3:40 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:41 AM
Points: 3,930, Visits: 5,119
try executing the bcp using the databse name as well
databaseName.schema.table



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #955394
Posted Tuesday, July 20, 2010 4:03 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 2:41 AM
Points: 8, Visits: 26
Can you give me an example code as follow as my code!!! Thanks.
Post #955406
Posted Tuesday, July 20, 2010 5:12 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:41 AM
Points: 3,930, Visits: 5,119
exec master..xp_cmdshell 'bcp "select * from DM_SCNYLDMS03_docbase.dbo.auditrec order by scnyl_pol_no desc" queryout "D:\AuditExport\Report\temp_policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt" -U scnyl\Administrator -P Passwords1 -S DISERVE-DB-01 -c -T -t ";"'



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #955440
Posted Tuesday, July 20, 2010 9:44 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 2:41 AM
Points: 8, Visits: 26
Error :
[SQL Native Client]Named Pipes Provider: Could not open a connection
to SQL Server [2].
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a
connection to the server. When connecting to SQL Server 2005, this
failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections.


1. Already opened DBEngine Remote Service with "Using both TCP/IP and named pipes"
2. Add in "C:\windows\system32\drivers\etc\hosts" of the other server (it use to connect to DISERVE-DB-01.) as below
192.168.1.21 DISERVE-DB-01

How can i do next????? Many thanks for your advice.

Post #956057
Posted Wednesday, July 21, 2010 1:47 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:41 AM
Points: 3,930, Visits: 5,119
One point - I notice that you pass user name (-U) & password (-P), and tell bcp to use a trusted connection (-T) (i.e. user name and password not to be supplied)
This would effectively confuse the bcp process
try this:
exec master.sys.xp_cmdshell 'bcp "select * from DM_SCNYLDMS03_docbase.dbo.auditrec order by scnyl_pol_no desc" queryout "D:\AuditExport\Report\temp_policies_log-%date:~10%%date:~4,2%%date:~7,2%.txt" -S DISERVE-DB-01 -n -T -t ";"'



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #956156
Posted Wednesday, July 21, 2010 9:54 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 2:41 AM
Points: 8, Visits: 26
Many thanks for your advice. It's perfect solution.
Post #956912
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse