Click here to Skip to main content
15,888,461 members
Home / Discussions / Database
   

Database

 
AnswerRe: Need help with what seems to be an easy SQL query.... Pin
James Shao13-Jan-10 13:57
James Shao13-Jan-10 13:57 
AnswerRe: Need help with what seems to be an easy SQL query.... Pin
Niladri_Biswas14-Jan-10 16:27
Niladri_Biswas14-Jan-10 16:27 
Questionavg (sqlite) Pin
jashimu13-Jan-10 3:39
jashimu13-Jan-10 3:39 
AnswerRe: avg (sqlite) Pin
James Shao13-Jan-10 4:36
James Shao13-Jan-10 4:36 
GeneralRe: avg (sqlite) [modified] Pin
jashimu13-Jan-10 5:00
jashimu13-Jan-10 5:00 
AnswerRe: avg (sqlite) Pin
loyal ginger13-Jan-10 5:44
loyal ginger13-Jan-10 5:44 
AnswerRe: avg (sqlite) Pin
Niladri_Biswas14-Jan-10 16:49
Niladri_Biswas14-Jan-10 16:49 
QuestionMS SQL Server 2005 UDF only returns first character from a string value Pin
Steven J Jowett13-Jan-10 1:40
Steven J Jowett13-Jan-10 1:40 
I have written a small Scalar UDF that excepts a VarChar value and check to see if the value is NULL.
If the value is null an empty string should be returned else the value passed to the UDF should be returned.

If the value is NULL an empty string is returned, so that bit works fine, but is I do something like this:-

SELECT dbo.NullToString('Hello world')


The value returned by the UDF is 'H', where I would expect 'Hello world'

Here's the UDF code, hopefully someone can enlighten me to my mistake.

CREATE FUNCTION NullToString 
(
     @value VarChar(255)
)
RETURNS VarChar
AS
BEGIN
     DECLARE @ReturnValue VarChar(255)
     IF(@value Is NULL)
	BEGIN
	    SET @ReturnValue = ''
	END
     ELSE
	BEGIN
	    SET @ReturnValue = @value
	END

     RETURN @ReturnValue
END
GO


Thanks

Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.

AnswerRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
Covean13-Jan-10 1:44
Covean13-Jan-10 1:44 
AnswerRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
J4amieC13-Jan-10 2:17
J4amieC13-Jan-10 2:17 
GeneralRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
Steven J Jowett13-Jan-10 4:25
Steven J Jowett13-Jan-10 4:25 
GeneralRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
Ashfield13-Jan-10 5:15
Ashfield13-Jan-10 5:15 
GeneralRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
Steven J Jowett13-Jan-10 5:21
Steven J Jowett13-Jan-10 5:21 
GeneralRe: MS SQL Server 2005 UDF only returns first character from a string value Pin
Ashfield13-Jan-10 8:36
Ashfield13-Jan-10 8:36 
Questionupdate Query with Order by Clause- SQL Server2008 Pin
Paramu197311-Jan-10 22:51
Paramu197311-Jan-10 22:51 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
Mycroft Holmes11-Jan-10 23:21
professionalMycroft Holmes11-Jan-10 23:21 
GeneralRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 3:54
i.j.russell12-Jan-10 3:54 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 3:57
i.j.russell12-Jan-10 3:57 
AnswerRe: update Query with Order by Clause- SQL Server2008 [modified] Pin
loyal ginger12-Jan-10 4:06
loyal ginger12-Jan-10 4:06 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
Corporal Agarn12-Jan-10 5:10
professionalCorporal Agarn12-Jan-10 5:10 
GeneralRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 5:15
i.j.russell12-Jan-10 5:15 
QuestionGetting underlying table-column value from a selected DataGridRow [Solved] Pin
AussieLew11-Jan-10 18:07
AussieLew11-Jan-10 18:07 
AnswerRe: Getting underlying table-column value from a selected DataGridRow Pin
Mycroft Holmes11-Jan-10 18:40
professionalMycroft Holmes11-Jan-10 18:40 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
AussieLew11-Jan-10 21:27
AussieLew11-Jan-10 21:27 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
Mycroft Holmes11-Jan-10 22:12
professionalMycroft Holmes11-Jan-10 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.