Job fails

  • Hi all

    Every night I am executing a job and it fails. The job is this SQL statement:

    INSERT INTO database.dbo.Customers

    SELECT "Name", "Address", "Address 2", "Post Code", "City", "Phone No_", "Telex No_", "No_" FROM "Second Database"."dbo"."Customer"

    WHERE "No_" NOT IN (

    SELECT database.dbo.Customers.Customer_ID FROM database.dbo.Customers

    ) ;

    The error I receive is this:

    Message

    Executed as user: Domain\sqlservice. Incorrect syntax near 'Second Database'. [SQLSTATE 42000] (Error 102). The step failed.

    The user Domain\sqlservice is SA. When I execute the same statement in Manegement studio I don't get any error.

    Could you please help me?

    Regards

    Bo

  • Good Day,

    Try and put square brackets "[]" around Second Database, it could be the space between the two names that is causing the issues.

    You can also try and remove the "" if you are running this through a SQL Statement.

    Regards

    Stephen

  • The [] brackets worked. Thank you

    Bo

  • While specifying th Four naming part its a good habit to specify them with square backets ...

    [Server Name].[Database Name].[Schema].[Table Name]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply