Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:54+00:00 2026-06-18T05:33:54+00:00

I have a table User_Table in SQL Server 2008, there is a column UserAvatar

  • 0

I have a table User_Table in SQL Server 2008, there is a column UserAvatar (varbinary) that it can be null.

I need a query that returns the user avatar if it’s not null and if it is null return the default user avatar that is saved in a specific row (there is a column named ID that is PK)

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:33:55+00:00Added an answer on June 18, 2026 at 5:33 am
    CREATE PROCEDURE sp_myDuplicateCheck
     @ID int,
    @UserAvatar varbinary,
    AS
    BEGIN
    SET @UserAvatar = Select UserAvatar from User_Table where ID=@ID
    IF (@UserAvatar IS NULL)
    Set @UserAvatar = Select UserAvatar from User_Table where ID=xxDefault
    END
    END
    

    You can do the logic in SP and call the SP from Code and get the data.

    Other Option is you can do same Logic on your code
    Select UserAvatar from User_Table where ID=XX
    by using http://msdn.microsoft.com/en-us/library/tckcces5%28v=vs.80%29.aspx
    IsDBNULL

    if (dr["nameOfField"] == System.DBNull.Value) //Here Dr is your Data reader 
    {
        nedID = 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database with a table that contains a FILESTREAM
I have user table in SQL Server 2008 r2. Nothing there is encrypted yet
I have a table that contains a GEOMETRY data type. SQL Server 2008 ships
In SQL Server 2008 I have a user table like the following: Userid Username
In SQL Server 2008 I have two tables. One table for users: id_user -
In SQL Server, I need to design a User table. It should have a
I have an user defined table function in SQL Server that aggregate data from
I have some extended property column descriptions in a SQL Server 2008 database, and
I have a question about User-Defined Table Types in SQL Server 2008. For the
I have a stored procedure that retrieves sensitive information from an SQL Server 2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.