By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,362 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,362 IT Pros & Developers. It's quick & easy.

Conversion failed when converting from a character string to uniqueidentifier

P: 15
Hi,
i have a field createdby with datatype GUID.
In following query ,i encountered with the error
"Conversion failed when converting from a character string to uniqueidentifier"

select
ISNULL(VW_tbl_ChildProducts.createdBy,' ' ) as createdBy
from table.


it is running with sql server 2005, but not supporting by sql 2000.
what is the synax in 2000?
Apr 19 '08 #1
Share this Question
Share on Google+
2 Replies


P: 44
Hi,
i have a field createdby with datatype GUID.
In following query ,i encountered with the error
"Conversion failed when converting from a character string to uniqueidentifier"

select
ISNULL(VW_tbl_ChildProducts.createdBy,' ' ) as createdBy
from table.


it is running with sql server 2005, but not supporting by sql 2000.
what is the synax in 2000?

Empty string cannot be used for ISNULL place holder, instead 0x00 should be used for the same

Expand|Select|Wrap|Line Numbers
  1. select
  2. ISNULL(VW_tbl_ChildProducts.createdBy,0x00 ) as createdBy
  3. from table.
  4.  
Apr 19 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Hi,
i have a field createdby with datatype GUID.
In following query ,i encountered with the error
"Conversion failed when converting from a character string to uniqueidentifier"

select
ISNULL(VW_tbl_ChildProducts.createdBy,' ' ) as createdBy
from table.


it is running with sql server 2005, but not supporting by sql 2000.
what is the synax in 2000?

An empty may be placed as placeholder for ISNULL.

As in

Expand|Select|Wrap|Line Numbers
  1. declare @x as varchar(5)
  2.  
  3. select isnull(@x,' ')
When using ISNULL, you have to make sure that the value that will be used in replacement of the field being checked may be used to replace the field being checked. So if the field is datetime, the replacement value should also be datetime or at least may be converted into datetime.

It looks like you're checking a column that is a uniqueidentifier data type but you're replacing it with a string/varchar.

Read more about uniqueidentier here

-- CK
Apr 19 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.