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].[produc t]
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].[produc t]
SET @ProdID = @ProdID + 1
INSERT INTO [ALKLicense].[dbo].[produc t]( [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].[licPol icy]([prod ID],[numUn iqueDevice s],[matchB aseLicOnly ])
VALUES(
@prodID,
@numUniqueDevices,
@matchBaseLicOnly
)
END
return @inserted
END
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].[produc
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].[produc
SET @ProdID = @ProdID + 1
INSERT INTO [ALKLicense].[dbo].[produc
[prodLicEncKey], [supported], [licVersion], [prodAltCode] )
VALUES(
@prodID,
@prodCode,
@prodName,
@prodDesc,
@pfID,
@prodLicName,
@prodLicEncKey,
@supported,
@licVersion,
@prodAltCode
)
--SET @prodID = scope_identity()
INSERT INTO [ALKLicense].[dbo].[licPol
VALUES(
@prodID,
@numUniqueDevices,
@matchBaseLicOnly
)
END
return @inserted
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER