Click here to Skip to main content
15,917,606 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Why is this showing error,

asks me declare the @roleID parameter or variable Even though I did already

Here is my code:-

SQL
DECLARE @User VARCHAR(200)
SET @User = '1,3'
declare @roleID int
set @roleid=2
insert into userrole values((Select * from dbo.CSVToTable(@User) as UserID ,@roleID)


Please help
Posted
Comments
ganesh.dks 7-Jun-14 16:25pm    
Nope that didn't solve the issue,

DECLARE @User VARCHAR(200)
SET @User = '1,3'
declare @ROLEID int
declare @USERID int
set @ROLEID=2
insert into userrole values(@UserID in (Select * from dbo.CSVToTable(@User) ,@ROLEID)

The issue arises when I put that @UserID in (Select * from dbo.CSVToTable(@User) in the insert statement, I am not that good at sql. Shouldn't I use it that way.
ganesh.dks 7-Jun-14 16:28pm    
And swiggly line isn't just showing, there is indeed something wrong, Since I am not good at sql I am unable to figure out.
Simon_Whale 7-Jun-14 18:36pm    
is the CSVToTable a function that returns a row or many rows depending on what you have sent to it?

1 solution

declare @roleID int

The declaration is in upper and lower case, but your usage of said variable:
set @roleid=2

is all lower case. You should fix that to read:

set @roleID=2


to match the declaration of the variable.

Cheers!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900