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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 COALESCE GUID datatype to int

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2009-02-28 : 04:58:52
hi

Cast(COALESCE(s.ProdID,null) as nvarchar(100)

The ProdID is a GUID datatype and how do i replace a 0 instead of null? I need to return as int. Thanks

trellend
Starting Member

9 Posts

Posted - 2009-02-28 : 05:42:28
IsNUll(s.ProdId, 0)

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-28 : 06:06:37
A GUID cannot display a single 0 due to it's nature.
DECLARE	@Sample TABLE
(
ProdID UNIQUEIDENTIFIER
)

INSERT @Sample
SELECT NEWID() UNION ALL
SELECT NULL

SELECT ProdID,
COALESCE(CAST(ProdID AS VARCHAR(36)), '0') AS Peso
FROM @Sample



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2009-02-28 : 09:35:20
Thanks
Go to Top of Page
   

- Advertisement -