Monday, February 20, 2012

Query Syntax Error

This thing is giving me 'Incorrect syntax near the keyword declare'. What's the correct form?

declare @.Query varchar(8000)

set @.Query = 'insert into PortfolioStock (PortfolioID, StockSymbol) select ' + cast(@.Portfolio as varchar) + ', StockSymbol from PortfolioStock where StockSymbol in (''' + replace(ltrim(rtrim(@.Textbox)), ' ', ''', ''') + ''')'

exec @.Queryexec(@.Query)

No comments:

Post a Comment