Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in select statement

Status
Not open for further replies.

mevasquez

Programmer
Aug 26, 2003
75
US
I keep getting the error "Syntax error converting the varchar value 'division_muster' to a column of data type int. The table consist of many different types of permissions and I am passing a varchar variable @strPerms which contains the name of a field. When I run the following code I get the error.
Code:
DECLARE @strPerms VARCHAR(50)

SET @strPerms = 'division_muster' [COLOR=green]' This is passed from the Web page [/color]

Select * from personnel P
Left Outer Join permission PE on P.pid=PE.pid 
where (@strPerms = 1)
and is active = 1
order by lname,fname
This table consists of fields, which are the types of permissions.

TIA

Mike
 
You can't use a variable for a column name. You will need to use dynamic sql to run this type of query. Search on this forum, there have been many posts relating to this issue. Also, check the FAQs section.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top