Solved

Uniqueidentifier

Posted on 2001-07-18
4
323 Views
Last Modified: 2012-08-14
When I return a recordset from the database and it has a uniqueidentifier. It returns the guid with the squirly brackets around the guid eg.
{4559EBAB-D407-4F37-BF15-8103FFB8B635}.

If I take this guid and do and insert with this guid into another table on my database. Everything works fine.

Now we have a staging server. We backed up and restored my database to this server. Put all the same dll's on this machine.

But when I try do an insert using this guid with the brackets around it, I get the following error: "Error converting a varchar to a uniqueidentifier". If I change my connection string to point to the staging servers database, I don't get the same error.

The staging server and my machine are both running the same dll's and have the same version of SQL.
Does anyone have any idea, why I would be getting this problem.
0
Comment
Question by:JohnRock
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
lozzamoore earned 100 total points
ID: 6293016
What client tool are you using to do the inserts?
Also, what version of SQL Server for both servers?

Normally, query analyser returns the guids without curly brackets and they can be inserted as standard text fields
(SQL 7 and 2000)
I don't think uniqueidentifier is a supported data type in SQL 6.5 so you can't be using that(?)

eg.
insert guidtest values ('DA561AE4-7090-11D5-9DDD-00D0B73E502C', ...)

Cheers.
0
 

Author Comment

by:JohnRock
ID: 6293056
You see that's the problem when I return the guid, the guid is wrapped with curly brackets. Then when I do an insert using this value, I get the conversion error from varchar to uniqueidentifier.

We are using SQL 2000.

Storing the value as text, would probably solve the problem, but I am interested, as to why this would work on my version with the same database, and not on the staging server database.
0
 

Author Comment

by:JohnRock
ID: 6293071
About the client tool, I'm using ado, to do the insert.
0
 

Author Comment

by:JohnRock
ID: 6293597
Sorry for wasting you're time, I found the problem, it actually has something to do with special characters in the attribute tags of my xml string that I was returning using the persist method from the ado recordset.

But thanks for you're help.

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question