Conversion failed when converting from a character string to uniqueidentifier

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bipinskulkarni
    New Member
    • Dec 2007
    • 15

    Conversion failed when converting from a character string to uniqueidentifier

    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 uniqueidentifie r"

    select
    ISNULL(VW_tbl_C hildProducts.cr eatedBy,' ' ) as createdBy
    from table.


    it is running with sql server 2005, but not supporting by sql 2000.
    what is the synax in 2000?
  • siva538
    New Member
    • Jun 2007
    • 44

    #2
    Originally posted by bipinskulkarni
    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 uniqueidentifie r"

    select
    ISNULL(VW_tbl_C hildProducts.cr eatedBy,' ' ) 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

    Code:
    select
    ISNULL(VW_tbl_ChildProducts.createdBy,0x00 ) as createdBy
    from table.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by bipinskulkarni
      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 uniqueidentifie r"

      select
      ISNULL(VW_tbl_C hildProducts.cr eatedBy,' ' ) 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

      Code:
      declare @x as varchar(5)
      
      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 uniqueidentifie r data type but you're replacing it with a string/varchar.

      Read more about uniqueidentier here

      -- CK

      Comment

      Working...