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 |
fernandomierhicks
Starting Member
2 Posts |
Posted - 2007-12-29 : 16:28:12
|
Hi:I am trying to create a stored procedure that filters some customers. The field in wich I am trying to apply the filter is the age field. The problem is that I need to be able to select the comparison operator =,<,>,=<,>=,<>.I was trying to do it with the following code:Select CustomerName From Customer Where(CustomerAge & @Operator & @Age)But sql Server shows an error telling me that @Operartor couldnt be converted to int.I dont know if I am in the right track or way off, how is this done? |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-12-29 : 21:57:00
|
It's not valid t-sql statement, check syntax in books online. |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-30 : 00:39:33
|
You could write a lot of IF logic or use dynamic SQL.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
fernandomierhicks
Starting Member
2 Posts |
Posted - 2007-12-31 : 01:37:56
|
Thanks just one little problem.When I am finished making the procedure and I go to Visual Studio and try to drag the dataset into a form nothing happens, is like somehow the querry returned zero columns, if I add a "Select * From Customers" statement to the dyanmic Sql procedure then I am able to drag the dataset I dont know how to solve this.Thanks in Advance |
 |
|
|
|
|