Insufficient result space to convert uniqueidentifier value to char.

Posted by Vuyiswamb under Error and Solution on 9/15/2011 | Points: 10 | Views : 29707 | Status : [Member] [MVP] [Administrator] | Replies : 3

When you access a Unique identifier field , you need to declare a varchar with dimension,

e.g


DECLARE @COMPANYID VARCHAR
SET @COMPANYID = (SELECT TOP 1 UniqueIdenField FROM testtable WHERE USER_ID = @USERID)


the problem with this is that the varchar that is being declared is too small for the unique identifier field , that is 32 characters long, so you need to provide the dimensions for every variable you create as depicted below



DECLARE @COMPANYID VARCHAR(50)
SET @COMPANYID = (SELECT TOP 1 UniqueIdenField FROM testtable WHERE USER_ID = @USERID)



Thanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: Lokesh76 on: 9/16/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks, good thing to know.

Thanks
Lokesh Kumar

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 9/16/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
@Vuyiswamb

Kindly have a note - The UniqueIdentifier data is 36 characters length.

By default, The VARCHAR data type comsumes 1 character (Declare @Data Varchar)

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 9/16/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Correct

Thank you for posting at Dotnetfunda
[Administrator]

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response