Assuming the name is not nullable and that Id
is unique so can match at most one row.
SELECT
ISNULL(MAX(Name),'John Doe')
FROM
Users
WHERE
Id = @UserId
More Related Contents:
- Calculating distance between two points (Latitude, Longitude)
- How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM in SQL Server 20008R2?
- T-SQL split string based on delimiter
- WHERE Clause vs ON when using JOIN
- Partition Function COUNT() OVER possible using DISTINCT
- CREATE TABLE IF NOT EXISTS equivalent in SQL Server [duplicate]
- Cannot use UPDATE with OUTPUT clause when a trigger is on the table
- CASE WHEN statement for ORDER BY clause
- How to get last 7 days data from current datetime to last 7 days in sql server
- Script to kill all connections to a database (More than RESTRICTED_USER ROLLBACK)
- Reference an alias elsewhere in the SELECT list
- Using IF ELSE statement based on Count to execute different Insert statements
- How to find out what is locking my tables?
- Passing dynamic order by in stored procedure
- Select SQL Server database size
- Check if table exists and if it doesn’t exist, create it in SQL Server 2008
- How do I find the data directory for a SQL Server instance?
- How to concatenate all columns in a select with SQL Server
- How to automatically generate unique id in SQL like UID12345678?
- How can I do an UPDATE statement with JOIN in SQL Server?
- The multi-part identifier could not be bound
- How to insert a line break in a SQL Server VARCHAR/NVARCHAR string
- SQL Query to get aggregated result in comma separators along with group by column in SQL Server
- Fastest way to update 120 Million records
- how can I Update top 100 records in sql server
- Is there a SELECT … INTO OUTFILE equivalent in SQL Server Management Studio?
- How can I compare time in SQL Server?
- SQL – Difference between COALESCE and ISNULL? [duplicate]
- Improve SQL Server query performance on large tables
- T-SQL Skip Take Stored Procedure