views:

347

answers:

2

We are using a SQL Native Client to connect to a local SQL Server 2005 from a Boarland application. It will fine for selects, inserts, and updates. When we delete we get the error:

Could not find server 'SERVERNAME\SQLEXPRESS' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers

The default instance, the only instance, is SERVERNAME\SQLEXPRESS, and we are not using linked servers. Any ideas? I believe we moved the MDF and LDF files to a new server for this DB, and then reattached it.

Update 1

There is no SQL. This is all happening through programmatic interaction with cursors. It is an ODBC driver using ADO. You run TableObj->Delete to remove the record.

A: 

Can you post your SQL for the DELETE stmt? Sounds suspiciously like a foreign key violation...

squillman
A: 

Got it. I ran

SELECT @@servername

That returned the old host name of the box. I than ran

sp_dropserver 'OLDHOSTNAME\SQLEXPRESS'
go
sp_addserver 'NEWHOSTNAME\SQLEXPRESS', local

I then got

Server 'NEWHOSTNAME\SQLEXPRESS' is not configured for DATA ACCESS

I ran

sp_serveroption 'ICS-POS3-NEW\SQLEXPRESS', 'data access' , 'true'

This got me the error

Transaction context in use by another session

Which is because of linked servers. I found that the local option on the add server did not take affect until I restarted the server. I restarted, then it just worked.

Anthony D