SP for inserting to table using subquery

  • I have a view "[DCC_DB].[dbo].[DCCview]" from which I want to write its

    entire contents into another table in another database "[CC_Search].[dbo].[Professional]"

    but when I try to create the SP it does not like the syntax around "SELECT" and my ")" below... Any ideas?

    USE [DCC_DB]

    GO

    SET ANSI_NULLS OFF

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE PROCEDURE [dbo].[populateDCCintoSearch]

    AS

    BEGIN

    SET NOCOUNT ON;

    INSERT INTO [CC_Search].[dbo].[Professional] ([FirstName],

    [LastName],[City],[State],[Country],[Certifications],

    [OriginalDatabaseId],[RegionId],[IsOnCounselorFind],[PostalCode],[OriginalDatabase])

    VALUES (SELECT [FirstName],

    [LastName],[City],[State],[Country],[Certifications],

    [OriginalDatabaseId],[RegionId],[IsOnCounselorFind],[PostalCode],[OriginalDatabase]

    FROM [DCC_DB].[dbo].[DCCview])

    END

    GO

  • I found the problem... I didn't need the word VALUES or the parentheses.

Viewing 2 posts - 1 through 1 (of 1 total)

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