473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

uniqueidentifier Type

26
Hi all, need some help. I have a table called my_table say, and there is a uniqueidentifier field in that table say my_column.
When I execute this query, I get back a row

select * from my_table where
my_column = 'B844EC98-F509-4F41-BC42-301DD22F6A12'

But, when I change the string value by changing any of the characters, I get an error stating

Server: Msg 8169, Level 16, State 2, Line 1
Syntax error converting from a character string to uniqueidentifier.


However, if I change any of the numbers in the string, I do not get any data, but also I get no errors.
Can anyone please explain why this happens? Is it so, that for uniqueidentifier columns, there are only a fixed set of characters, but numbers may alter? I am new to SQL Server, so it will be great if someone helps me out(I have replaced one character by those characters which are already present in the string itself, I don't get any errors. But suppose I replace D by X, I get an error)
Aug 27 '07 #1
3 4938
azimmer
200 Expert 100+
Hi all, need some help. I have a table called my_table say, and there is a uniqueidentifier field in that table say my_column.
When I execute this query, I get back a row

select * from my_table where
my_column = 'B844EC98-F509-4F41-BC42-301DD22F6A12'

But, when I change the string value by changing any of the characters, I get an error stating

Server: Msg 8169, Level 16, State 2, Line 1
Syntax error converting from a character string to uniqueidentifier.


However, if I change any of the numbers in the string, I do not get any data, but also I get no errors.
Can anyone please explain why this happens? Is it so, that for uniqueidentifier columns, there are only a fixed set of characters, but numbers may alter? I am new to SQL Server, so it will be great if someone helps me out(I have replaced one character by those characters which are already present in the string itself, I don't get any errors. But suppose I replace D by X, I get an error)
IMHO it's best to treat uniqueidentifiers SQL Server internal structures which you do not want to manipulate by hand like that. They are usually assigned to column automatically (by setting the default to the newid() function), and one usually uses them to select a specific row (or rows) -- usually in joins, sometimes in other operations (esp. DELETE). If I were you I wouldn't want to make out the internals of uniqueidentifiers unless there's absolutely no other way.
If you do want to play around with it keep in mind: each position is a hex digit, so valid letters are 'A'..'F' only.
Aug 27 '07 #2
almaz
168 Expert 100+
However, if I change any of the numbers in the string, I do not get any data, but also I get no errors.
Can anyone please explain why this happens? Is it so, that for uniqueidentifier columns, there are only a fixed set of characters, but numbers may alter? I am new to SQL Server, so it will be great if someone helps me out(I have replaced one character by those characters which are already present in the string itself, I don't get any errors. But suppose I replace D by X, I get an error)
Uniqueidentifier type (also called GUID, "Globally Unique IDentifier") have a standard text representation of "8chars-4chars-4chars-4chars-12chars", where each character is a hexadecimal digit (0-9, A-F). See GUID for more information.
Aug 27 '07 #3
qhjghz
26
IMHO it's best to treat uniqueidentifiers SQL Server internal structures which you do not want to manipulate by hand like that. They are usually assigned to column automatically (by setting the default to the newid() function), and one usually uses them to select a specific row (or rows) -- usually in joins, sometimes in other operations (esp. DELETE). If I were you I wouldn't want to make out the internals of uniqueidentifiers unless there's absolutely no other way.
If you do want to play around with it keep in mind: each position is a hex digit, so valid letters are 'A'..'F' only.

"If you do want to play around with it keep in mind: each position is a hex digit, so valid letters are 'A'..'F' only" That's the answer I was looking for. Thanks a lot. That is the reason why when I try to substitute "b" BY "X", it does not work, but when I replace it by "A", it works
Aug 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jacques Wentworth | last post by:
Hi I have the following problem. I have a SQL Server (2000) Stored Proc that with 4 parameter (one being @UnlockKey uniqueidentifier OUTPUT). I run it from Query Analyzer and the @Key parameter...
5
by: turnstyle | last post by:
Hi all, I'm trying to run a select where a uniqueidentifier/GUID equals a hex, but I don't seem to be getting matches. For example, this query returns the expected record: select * from...
4
by: christopher.secord | last post by:
I have a table that contains articles (as in, newspaper articles, blog articles, whatever). I need to use a column of type uniqueidentifier because one of the requirements is that I be able to...
2
by: Carl | last post by:
Hi, I do have one dataset from SQL server with a field (bound) to Textbox called txtID , this field is of type uniqueidentifier. From the doc, they say the equivalent is GUID in dot net, ...
3
by: SMG | last post by:
Hi all, I created one table with following structure, and bound the same with a DataGird. But I am not able to see any column which is having 'uniqueidentifier' as datatype. Name ...
1
by: dawg1998 | last post by:
I am attempting to create a record that has a uniqueidentifier datatype. I am receiving the following error each time I attempt the Insert: Incorrect syntax near '-' The following is the code...
3
by: blazeboy | last post by:
Hello, I am using a SQL data source to insert records into a table. The table uses a GUID as the primary key (GoalEventID), and a GUID for a second field (GoalID) as a foreign key. When I call...
5
by: DotNetNewbie | last post by:
Hi, I am developing an application that has to scale and be very efficient, and I am using asp.net membership in my application. I set things up in my Users table (it has extra columns that I...
8
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Vb.net 2005 app I am looking up records in a sql 2005 database and I grab the uniqueidentifier and put it into a variable (gID) of type GUID. When I try to create a new record in a new table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.