Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
haseeb1431
Starting Member
3 Posts |
Posted - 2009-09-12 : 13:07:14
|
| my query returns five rows as 1.null2.celap3.null4.null5.nullwhen i use the coalesce to get the data as a single string it works fine for other data but for this it reutrns null and i am excepting it to return celaphere is my query as functionALTER function [dbo].[abc](@dep varchar(50),@rollno int)returns varchar(200)asbegindeclare @has varchar(200)select @has=coalesce(@has,'','')+( (select branchcode from branch where branchname=department and campusid=substring(campus,1,1)) +category)+',' from f1preferences where rollno=@rollno anddepartment=@dep--'Electrical Engineering'order by studentpreferencereturn @hasend |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-12 : 13:12:06
|
try select isnull(branchcode,'') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-12 : 13:38:43
|
and also isnull(category,'') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
haseeb1431
Starting Member
3 Posts |
Posted - 2009-09-13 : 08:23:32
|
| i have tried isnull but not working too! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-13 : 13:21:07
|
| are you sure its null and not string 'null'? |
 |
|
|
haseeb1431
Starting Member
3 Posts |
Posted - 2009-09-15 : 14:20:37
|
| these are blank fields of datatype varchar |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-16 : 13:07:05
|
| and you want it as null? your sample data shows the column to contain null values? |
 |
|
|
|
|
|