SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
nuengharit
nuengharit
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 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!
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8781 Visits: 7279
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”
nuengharit
nuengharit
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 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!!!
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8781 Visits: 7279
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”
nuengharit
nuengharit
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 26
Can you give me an example code as follow as my code!!! Thanks.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8781 Visits: 7279

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”
nuengharit
nuengharit
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 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.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8781 Visits: 7279
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”
nuengharit
nuengharit
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 26
Many thanks for your advice. It's perfect solution.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search