Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Inserting 2 fields in a row using a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-11-09 : 08:19:16
Doug writes "Hi,

I am having trouble inserting 2 fields in a row using a stored procedure.

This works fine:

Exec ('Insert Into NumbersPull (Number)'+ @SQL)

but when I try to insert another value into field 2 it errors out:

I try this:

Exec ('Insert Into NumbersPull

(Number,resultID) Select ('+ @SQL

+ '),' + @resultID'

)

and get this error:

ERROR: Line 2: Incorrect syntax near ')'.

Thanks,

Doug"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-09 : 08:30:32
[code]exec ('Insert Into NumbersPull (Number,resultID) Select ' + @SQL + ',' + @resultID [/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-09 : 11:16:41
Why are you using Dynamic SQL?

Insert Into NumbersPull (Number,resultID) Select @SQL,@resultID



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -