ALTER PROCEDURE dbo.ClasificacionSelectTodas
(
@.visibilidad bit = 1
)
AS
SET NOCOUNT ON
SELECT Clas_Id, Clas_Madre, Clas_Titulo, Clas_Descripcion, Clas_Prioridad, Clas_Visibilidad
FROM Clasificacion
WHERE (Clas_Visibilidad = @.visibilidad)
As you see, if I don't set any value to "@.visibilidad" it returns me the registries where visibilidad = 1
But what I want is that if I don't set any value to visibilidad, itturns to me all the registries. I was trying giving a default value tovisibilidad like "*" o "?", but it gives me an error.
Any idea?
Thanks
![Stick out tongue [:P]](http://pics.10026.com/?src=/emoticons/emotion-4.gif)
ALTER PROCEDURE dbo.ClasificacionSelectTodas
(
@.visibilidad bit = null
)
AS
SET NOCOUNT ON
SELECT Clas_Id, Clas_Madre, Clas_Titulo, Clas_Descripcion, Clas_Prioridad, Clas_Visibilidad
FROM Clasificacion
WHERE (Clas_Visibilidad = IsNull(@.visibilidad,Clas_Visibilidad))
This will compare Clas_Cisibilidad to the variable passed in (if not null) or with itself (which will always be true).|||Thanks douglas, it works great
![Stick out tongue [:P]](http://pics.10026.com/?src=/emoticons/emotion-4.gif)
Congratulations for your book!
|||Glad it helped.
Also, I am actually working on a new book, tentatively titledStreamlined Web Forms Development. Should be out by ASP.NET 2.0 release, and will make a great stocking suffer<g>.|||I'm sure it will be highly interesting, I'll wait for it ;)
No comments:
Post a Comment