all groups > sql server programming > may 2005 >
You're in the

sql server programming

group:

Query


RE: Query Alejandro Mesa
5/23/2005 4:51:03 PM
sql server programming:
Try,

select coalesce((select top 1 ParamValue FROM dbo.ParametersUsers where
UserId = 1713 and ParamName = 'showpopups'), 1) as ParamValue


AMB

[quoted text, click to view]
Query Aleks
5/23/2005 7:21:51 PM
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

RE: Query Chandra
5/23/2005 10:41:02 PM
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]
RE: Query Christian Donner
5/24/2005 7:11:28 AM
"Aleks" schrieb:

[quoted text, click to view]

IF EXISTS (SELECT *
FROM dbo.ParametersUsers
WHERE UserId = 1713 and ParamName = 'showpopups')
SET @ParamValue = 1
ELSE
SELECT @ParamValue = ParamValue
FROM dbo.ParametersUsers
RE: Query Christian Donner
5/24/2005 7:20:06 AM
Sorry - of course I meant:

IF NOT EXISTS (...
AddThis Social Bookmark Button