Hi, I my stored procedure I have an insert query. For this I have to get one value from a sub query. But it is not accepting that query. So I tried to declare a separate variable and assign the subquery value to this and insert it in the table.
Create Procedure [dbo].[AddOrRemoveFavourites] ( @UserId bigint, @VideoName varchar(50), ) as
Declare @VideoId int Set @VideoId = Select VideoId from Videos where Title='Monkeydog'
Insert into Favourites(UserId,VideoId) values(@UserId,@VideoId)
but in this I am getting error like "Incorrect syntax near the keyword 'Select'."
If anyone have any idea to solve this please reply me.
Thanks in advance.
|
| Author: soniumesh 05 Nov 2009 | Member Level: Gold | Rating:   Points: 3 |
Hi,
use this line as
Wrong : Set @VideoId = Select VideoId from Videos where Title='Monkeydog'
Right : Set @VideoId = (Select VideoId from Videos where Title='Monkeydog')
Regard, umesh soni
|
| Author: NekkantiDivya 05 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Thank you soniumesh.
It is working. Can you explain me the difference between those two queries
|