Toad World® Forums

INSERT SELECT with function

I am trying to perform an INSERT with a SELECT statement and when I add a function such as this:
INSERT INTO[DatabaseName].[dbo].[TABLEA]

       ([SSN]

       ,[NAME]

       ,[401k]

       ,[401kMatch]

       ,[Hours]

       ,[Roth])

 SELECT dbo.ConvertSSN (TABLEB.SocSecNum)AS SSN,

   TABLEB.[Employee Name] AS [NAME],

   TABLEB.[Employee 401(k) Deferrals] AS[401k],

   TABLEB.[Employer Match] AS [401kMatch],

   TABLEB.[2011 Hours] AS Hours,

   TABLEB.[Employee Roth 401(k) Deferrals]AS Roth

FROM DatabaseName.dbo.TABLEB TABLEB

The query fails in TOAD with: Lookup Error - SQL Server Database Error: Cannot find either column “dbo” or the user-defined function or aggregate “dbo.ConvertSSN”, or the name is ambiguous.

The same statement runs without issue in management studio. Is there something I need to configure to allow this to run in TOAD?

Edit: Newb errror - please igore - I neglected to set the correct database.

Message was edited by: tatchiso_937

Hi tatchiso_937,

just wonder what was the difference in your case that helped you to have proper database for the editor in management studio?