Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

SQL Server - 3 part naming Cannot be used when dropping Views,Functions or Procedures.

Dec 13 2011 9:06AM by Dattatrey Sindol (Datta)   

While dropping a table present in a different database, you can use the fully qualified Table Name ("DatabaseName.SchemaName.TableName" format) and drop the table as shown below.

DROP TABLE AdventureWorks.HumanResources.Department
GO

While the above statement is valid and will execute successfully, the following statements will throw an error.

DROP VIEW AdventureWorks.HumanResources.vEmployee
GO

DROP FUNCTION AdventureWorks.dbo.ufnGetContactInformation
GO

DROP PROCEDURE AdventureWorks.HumanResources.uspUpdateEmployeeHireInfo
GO

In the above scenarios, you need to change the database context using "USE <<Database>>" clause and run drop statements without the DatabaseName prefix.

Read More..   [0 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


Dattatrey Sindol (Datta)
43 · 4% · 1333
17
 
4
 
14
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

2  Comments  

  • The same holds true when creating objects.

    commented on Dec 14 2011 1:21AM
    pl80
    414 · 0% · 95
  • Whenever I've needed to drop or alter objects in another database, I've used sp_ExecuteSQL:

    This will fail:

    DROP VIEW AdventureWorks.HumanResources.vEmployee
    

    This will succeed:

    EXEC [AdventureWorks].[sys].[sp_ExecuteSQL] N'DROP VIEW HumanResources.vEmployee'
    
    commented on Dec 14 2011 6:55AM
    Marc Jellinek
    97 · 2% · 546

Your Comment


Sign Up or Login to post a comment.

"SQL Server - 3 part naming Cannot be used when dropping Views,Functions or Procedures." rated 5 out of 5 by 17 readers
SQL Server - 3 part naming Cannot be used when dropping Views,Functions or Procedures. , 5.0 out of 5 based on 17 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]