Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Uniqueidentifier

Posted on 2001-07-18
4
Medium Priority
?
333 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 300 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

885 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