Hi
Probably you are looking for this:
SELECT ISNULL(ParamValue,1), ...<other values>
FROM dbo.ParametersUsers
WHERE UserId = 1713 and ParamName = 'showpopups'
--
best Regards,
Chandra
http://chanduas.blogspot.com/ http://groups.msn.com/SQLResource/ ---------------------------------------
[quoted text, click to view] "Aleks" wrote:
> I need a little help with this query.
>
> I am querying the value of field, but I need to add to the logic that if
> there is no record then the value = 1
>
> This is the query as I have it:
>
> -------------
>
> SELECT *
> FROM dbo.ParametersUsers
> WHERE UserId = 1713 and ParamName = 'showpopups'
>
> ------------------
>
> How do I tell the query that "ParamValue" = 1 if no result is returned ?
>
> Thanks.
>
> Aleks
>
>
"Aleks" schrieb:
[quoted text, click to view] > I need a little help with this query.
>
> I am querying the value of field, but I need to add to the logic that if
> there is no record then the value = 1
>
> This is the query as I have it:
>
> -------------
>
> SELECT *
> FROM dbo.ParametersUsers
> WHERE UserId = 1713 and ParamName = 'showpopups'
>
> ------------------
>
> How do I tell the query that "ParamValue" = 1 if no result is returned ?
>
> Thanks.
>
> Aleks
>
IF EXISTS (SELECT *
FROM dbo.ParametersUsers
WHERE UserId = 1713 and ParamName = 'showpopups')
SET @ParamValue = 1
ELSE
SELECT @ParamValue = ParamValue
FROM dbo.ParametersUsers