Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insufficient result space to convert uniqueidentifier value to char.

Status
Not open for further replies.

maccaroo

Programmer
Jan 28, 2005
11
0
0
GB
Hi

I'm getting this very irritating message when trying to print a uniqueidentifier field for debug info. Here is my proposed string:

PRINT 'AuditID = ' + CAST(@AuditID AS varchar)

I've tried using an intermediary variable, but I just get the same error there:

SET @strPrint = ('AuditContactID = ' + CAST(@AuditContactID AS varchar))
PRINT @strPrint


I can work around it by simply using 2 PRINT statements, but I want to know what's causing this problem... Thanks in advance!
 
When using varchar without specifying a length in a CAST/CONVERT the default length is 30. This is not long enough to hold a uniqueidentifier value.

Code:
PRINT 'AuditID = ' + CAST(@AuditID AS varchar(50))

--James
 
Thanks James. Tried it and so far it works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top