sql stored procedure in visual studio 2008

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-06-08T11:20:57Z Indexed on 2010/06/08 11:32 UTC
Read the original article Hit count: 270

Hi,

I want to write stored procedure in visual studio that as a parameter recieves the name of project and runs in database TT and copies data from TT.dbo.LCTemp (where the LC is the name of the project recieved as a parameter) table to "TT.dbo.Points" table. both tables have 3 columns: PT_ID, Projectname and DateCreated

I think I have written it wrong, here it is:

ALTER PROCEDURE dbo.FromTmpToRegular
    @project varchar(10)
AS
BEGIN 
    declare @ptID varchar(20)
    declare @table varchar(20)

    set @table = 'TT.dbo.' + @project + 'Temp'
    set @ptID = @table + '.PT_ID'

    Insert into TT.dbo.Points Select * from [@table] where [@ptID] Not in(Select PT_ID from TT.dbo.Points)
END

Any idea what I did wrong?

Thanks! :)

Greg

© Stack Overflow or respective owner

Related posts about sql

Related posts about visual-studio-2008