Visual Studio 2013 generates SQL startup error

I am trying to add a trigger to a SQL table in Visual Studio 2013 but I am getting the error

SQL80001: Incorrect syntax near 'End Of File' Expecting '.'

This is the SQL code:

CREATE TRIGGER SomeMethod1 
ON UserTable 
AFTER INSERT AS 
    EXTERNAL NAME "Main.Site.Header1.OnEvent"

      

This is the first time I am trying to run SQL, so I may be missing something.

Anyone have an idea what the problem is?

+3


source to share


1 answer


In SQL Server, double quotes work the same as square brackets and delimit object names. For example:

SELECT * FROM "Customers"

      

Not needed here, but if the object name is complex you need to delimit it with either double quotes or square brackets

SELECT * FROM [Order Details]
SELECT * FROM "Order Details"

      

If the object belongs to multiple parts, such as a schema or a database, you will need to delimit each individual part rather than specifying a fully qualified name, as in: SELECT * FROM "dbo". "Clients" are not

SELECT * FROM "dbo.Customers"

      



In the code you showed, you have all four part names:

"Main.Site.Header1.OnEvent"

      

The EXTERNAL NAME requires three parts, the first is the assembly, the second is the class, and the third is the method. If you have a namespaced class, it has a two-part name. I'm guessing from context what you really want here:

Main."Site.Header1".OnEvent"

      

because Site is a namespace and Header1 is a class, so the second parameter needs to be delimited to specify a complex name, just like "Order Details", it needs to be delimited because it contains a space.

+1


source







All Articles