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.
| Author |
Topic |
|
sagimore
Starting Member
1 Post |
Posted - 2011-08-01 : 16:57:37
|
| Hello,Total Noob, but here goes. I am running a report on Visual Studios, SSRS. I have the following query set up.SELECT sFName, sLName, sLogin, sPassword, sEmail, sMemNum, sFName FROM dbo.MemberWHERE (sMemNum LIKE @AgentNumber) OR (sLogin LIKE @LoginName)Here is the parameter for the @ agentnumber= "%" & Parameters!AgentNumber.Value & "%"The @login = "%" & Parameters!LoginName.Value & "%"When I go to the Preview option to run the report, it will only run correctly, if I put something in both fields. If I have something in the AgentNumber Field but not the LoginName field it returns all the records in the table.Also if I remove the second parameter and the SQL statement for it, the search runs fine, its only after I add the second LIKE condition that it hoses up.Sorry I know this might not be the correct forum, but I wanted to register anyways since i'm new to SQL.Thanks. |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-08-01 : 20:59:57
|
Do two things. First, change the query to SELECT sFName, sLName, sLogin, sPassword, sEmail, sMemNum, sFNameFROM dbo.MemberWHERE (sMemNum LIKE '%'+@AgentNumber+'%') OR (sLogin LIKE '%'+@LoginName+'%') Second, change the parameters to Parameters!AgentNumber.Value and Parameters!LoginName.Value without the wild-card characters. |
 |
|
|
|
|
|
|
|