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)
 Stored Proc syntax question

Author  Topic 

endsabruptly
Starting Member

12 Posts

Posted - 2004-11-08 : 09:47:51
I'm attempting to insert variables as well as data from a select statement into a new table. However with the current syntax I am unsuccessful. Any ideas would be great.
IF @Williams <> '' 
BEGIN
INSERT INTO

EFM_READ

(SELECT
tp.Entity,
@ProdYear as ProdYear,
@ProdMonth as ProdMonth,
tp.Pipeline,
tp.Meter,
tp.DealID,
tp.Company,
@CompanyName as CompanyName,
tp.Producer,
tp.KConnect,
@EFM1 as EFM1,
@EFM2 as EFM2,
@EFM3 as EFM3,
@EFM4 as EFM4,
@EFM5 as EFM5,
@EFM6 as EFM6,
@EFM7 as EFM7,
@EFM8 as EFM8,
@EFM9 as EFM9,
@EFM10 as EFM10,
@EFM11 as EFM11,
@EFM12 as EFM12,
@EFM13 as EFM13,
@EFM14 as EFM14,
@EFM15 as EFM15,
@EFM16 as EFM16,
@EFM17 as EFM17,
@EFM18 as EFM18,
@EFM19 as EFM19,
@EFM20 as EFM20,
@EFM21 as EFM21,
@EFM22 as EFM22,
@EFM23 as EFM23,
@EFM24 as EFM24,
@EFM25 as EFM25,
@EFM26 as EFM26,
@EFM27 as EFM27,
@EFM28 as EFM28,
@EFM29 as EFM29,
@EFM30 as EFM30,
@EFM31 as EFM31,
@Total as MthTotal,
tp.FlowUnit as FlowUnit,
@LastChange as LastChange,
@LastChangeUser as LastChangeUser

FROM title tp

WHERE tp.Producer = @Williams
AND tp.ProdMonth = @ProdMonth
AND tp.ProdYear = @ProdYear
AND tp.Entity = '')


END

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-08 : 09:55:30
The error message would be good.
I'm guessing invalid syntax near select?

Remove the brackets around the seect statement

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -