[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Need to return " "

if this
   SELECT AboutME FROM tbl_Profile
   WHERE  UserID = @sUserId
returns null then I would like to return " "
a space textbox.

ALTER PROCEDURE [dbo].[sprGetAboutMeName]
(
   @sUserId nvarchar(50)
   
)
AS
BEGIN

   -- Unique Columns to check whether already exists
   SELECT AboutME FROM tbl_Profile
   WHERE  UserID = @sUserId
RETURN
END
0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 4
  • 3
  • 2
  • +1
4 Solutions
 
HugoHiaslCommented:
SELECT coalesce(AboutMe,'') FROM  tbl_Profile
   WHERE  UserID = @sUserId
0
 
TomeryosCommented:
free points for HugoHiasl haha ;)
0
 
HugoHiaslCommented:
*smile*
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mathieu_cuprykAuthor Commented:
Need to return "" epty string
no spaces
and I cannot return null
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try this:

ALTER PROCEDURE [dbo].[sprGetAboutMeName]
(
   @sUserId nvarchar(50)
   
)
AS
BEGIN
DECLARE @res NVARCHAR(1000)
SET NOCOUNT ON 
   -- Unique Columns to check whether already exists
   SELECT  @res = AboutME 
    FROM tbl_Profile
   WHERE  UserID = @sUserId

  SELECT ISNULL(@res, '') as AboutMe
  

END

Open in new window

0
 
mathieu_cuprykAuthor Commented:
Looks good I will try tomorrow morning thanks.
0
 
HugoHiaslCommented:
The version I wrote first did also return an empty string.
SQL does not use double quotes for strings but single quotes. So '' is the empty string.
0
 
mathieu_cuprykAuthor Commented:
I look at this they are identical solutions.
0
 
mathieu_cuprykAuthor Commented:
k
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the solutions are actually not identical.
mine will return exactly 1 row, and this even if there is no match for the :
WHERE  UserID = @sUserId
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now