Link to home
Start Free TrialLog in
Avatar of SirReadAlot
SirReadAlot

asked on

Incorrect syntax near the keyword 'SELECT'.

hi,

Does anyone know how to implement this:

I have two tables(table a and table b) which my client did not set to auto increment, both table have one similar column
called prodID,
so if i insert prodID 100 in table a, then it should prodID in table b.

i could implement this if the tables were set to increment, but i have been asked not to!!!

i got this error  

Incorrect syntax near the keyword 'SELECT'.

this line     SET @ProdID = SELECT MAX(prodID) FROM [ALKLicense].[dbo].[product]

 can't quite find the error, thanks
===============full code=========================================
ALTER PROCEDURE SPR_INSERT_PRODUCTS
      (
     
      @prodCode       varchar(10),
      @prodName       varchar(30),
      @prodDesc       varchar(200),
      @pfID           INT,
      @prodLicName    varchar(50),
      @prodLicEncKey  varchar(20),
      @supported      smallint,
      @licVersion     smallint,
      @prodAltCode    varchar(10),
      @numUniqueDevices int,
      @matchBaseLicOnly  int
      )
AS
BEGIN

DECLARE  @prodID  INT
Declare @Inserted int
IF EXISTS(Select * from product where prodName = @prodName)
BEGIN
  select @Inserted = 0
END
ELSE
    BEGIN
        SELECT @Inserted = 1
SET @ProdID = SELECT MAX(prodID) FROM [ALKLicense].[dbo].[product]
SET @ProdID = @ProdID + 1
INSERT INTO [ALKLicense].[dbo].[product]( [prodID], [prodCode], [prodName], [prodDesc], [pfID], [prodLicName],
 [prodLicEncKey], [supported], [licVersion], [prodAltCode] )
VALUES(
            @prodID,
            @prodCode,
            @prodName,
            @prodDesc,
            @pfID,
            @prodLicName,
            @prodLicEncKey,
            @supported,
            @licVersion,
            @prodAltCode
)

--SET @prodID = scope_identity()  

INSERT INTO [ALKLicense].[dbo].[licPolicy]([prodID],[numUniqueDevices],[matchBaseLicOnly])
VALUES(
         @prodID,
         @numUniqueDevices,  
         @matchBaseLicOnly
)
END
return @inserted
END

ASKER CERTIFIED SOLUTION
Avatar of Ved Prakash Agrawal
Ved Prakash Agrawal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SirReadAlot
SirReadAlot

ASKER

thanks