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 2005 Forums
 Transact-SQL (2005)
 erro in creating SP

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2011-01-25 : 04:30:04
Hi
May I know why it shows error--- Incorrect syntax near the keyword 'select'--- while creating the stored procedure

create procedure sp_test
@maxId bigint
as
Begin
set @maxId = select Isnull(max("productId"),0) from InventoryProductMaster
insert into tbltest(Id,val) values (@maxId,'hai')
End

Thanks and Regards
Anu Palavila

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-01-25 : 04:33:29
set @maxId = ( select Isnull(max("productId"),0) from InventoryProductMaster)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-01-25 : 04:34:00
The real quesion is why you are not using IDENTITY column in InventoryProductMaster table.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2011-01-25 : 04:39:25
sorry I dont want to pass the @maxId value, I am looking to correct the below SP

create procedure sp_test
as
Begin
@maxId bigint
set @maxId = (select Isnull(max("productId"),0) from InventoryProductMaster)
insert into tbltest(Id,val) values (@maxId,'hai')
End

Thanks and Regards
Anu Palavila
Go to Top of Page
   

- Advertisement -