1

Environment

  1. Azure SQL database (migrated from SQL Server)
  2. Old database originally (15 years+)
  3. Dealing with a single table (trying to delete records)
  4. Using an admin user
  5. Using SSMS 2014
  6. There are some triggers on the table (disabling them yields no change in error)
  7. Name of database is databasename in our example here
  8. There is an azure blob storage where files are stored and are "referenced" by an app via the records in said tblImages table -- but I cannot see any hard link between the two (is that even possible?)

I can select, insert and update records in this table, but cannot delete.

Failing Script

delete from
[databasename].[dbo].[tblImages]
where companyid = 123

Error:

Msg 40515, Level 15, State 1, Line 91 Reference to database and/or server name in 'Azure.dbo.tblImages' is not supported in this version of SQL Server.

But who said anything about "Azure.dbo.tblImages' ?!?

Things I've tried

  • Have tried fully qualifying the table name, and not - no change.
  • Have tried deleting records using the "edit top 200" feature, same error
  • tried disabling all triggers on the table, no change
  • tried script "create to new window" but nothing about linked databases/servers or other table constraints

Here's a simple test that succeeds with entirely same environment:

CREATE TABLE _tmpPersons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255) 
);

INSERT INTO _tmpPersons ( PersonID , LastName , FirstName , Address , City )
VALUES (123, 'Tore', 'Tess', '123 Main St.', 'Nowheresville');

select * from _tmpPersons;

delete from _tmpPersons where PersonId = 123;

select * from _tmpPersons;

I have already tried fully qualified [database].[schema].[table] and different combinations thereof.

It is definitely a table, and there ARE triggers, but disabling them changes nothing.

Zero results found from:

SELECT OBJECT_NAME(referencing_id), referenced_database_name
FROM sys.sql_expression_dependencies 
WHERE referenced_database_name IS NOT NULL;
1

Change your query from

delete from
[databasename].[dbo].[tblImages]
where companyid = 123

to

delete from
[dbo].[tblImages]
where companyid = 123
| improve this answer | |
1

David from MSDN forums put me on the right track; the error message was correct, you just have to find out WHERE the reference is.

  1. See what CASCADE DELETE FK constraints there are
  2. Inspect other table(s)
  3. See trigger on table with 3 part name in FROM clause
  4. Correct to 2 part name
  5. Dance

To see if there are FK relationships w/ DELETE CASCADE:

select * from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS where DELETE_RULE ='CASCADE'

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.