Hi,
I want to convert a UNIQUEIDENTIFIER to a VARCHAR, but I don't want to convert it to a varchar with this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; I want to convert it to a varchar representing my uniqueindentifier with a hexadecimal number 0xnnnnnnn...
Anybody knows if this is possible, or will I have to do it manipulating each character in the varchar
Thanks,
FedericoDepending on exactly what you want, there are two ways to get there... THe simple answer is to use:SELECT Cast(myGUID AS VARBINARY(20)) -- 20 is overkill, better safe than sorryIf that isn't sufficient for your needs, then a small UDF will allow you as much flexibility as you know how to code!
-PatP
Showing posts with label hexadecimal. Show all posts
Showing posts with label hexadecimal. Show all posts
Monday, March 19, 2012
Hexadecimal String
Hexadecimal format .mdf file
How to find the hexadecimal format of .mdf or .ldf file (sql database file)
I'm sorry, I don't understand your question, but this might be better suited in one of the SQL forums?
Quote:
Originally Posted by Avishkaar
How to find the hexadecimal format of .mdf or .ldf file (sql database file)
I'm sorry, I don't understand your question, but this might be better suited in one of the SQL forums?
Hexadecimal condition check and Identity columns
hi , i am using transactional replication between two Sql server 2000 . my
tables have identity columns as the primary keys with the identity property
set to Yes( not for replication). Now when I am generating the replication
intrinsic stored procs for the subscriber , I have a problem with the update
stored procs which are generated at the subscriber side. Each of these Update
command SPs ( which are each for a table) have two update statements in them
and a IF statement which chooses one of the udpate statements to run
depending on a binary hexa decimal field. If the condition satifies , it run
the first update query which unlike the second update query updates the
identity column as well and this update query is always selected by the
Update statement to run. The second if stement is run when the hexadicmal
conditions is not met and the funny part is that it never ever happens. I had
to comment out the part of the first update query which tried to update the
identity column. Now my queston are
1.why is replication trying to update the identity columns when it know
that they can not be updated.
2.What is the binary hexadecimal field used for, why is this the condition
in each and every case select statement in every field?
Please help me with this hexadecimal paradigm
The IF statement checks to see if the PK is being updated, and if so
executes the update statement differently. This is not related to identity
columns. If you have an identity column on the subscriber, compilation of
this procedure may fail. That's because the identity attribute shouldn't be
there - it's implicitly treated as read-only. If you had queued updating
subscribers the logic in these sps is different and there is no update or
insert into the identity columns because the identity attribute is expected
on the subscriber.
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
tables have identity columns as the primary keys with the identity property
set to Yes( not for replication). Now when I am generating the replication
intrinsic stored procs for the subscriber , I have a problem with the update
stored procs which are generated at the subscriber side. Each of these Update
command SPs ( which are each for a table) have two update statements in them
and a IF statement which chooses one of the udpate statements to run
depending on a binary hexa decimal field. If the condition satifies , it run
the first update query which unlike the second update query updates the
identity column as well and this update query is always selected by the
Update statement to run. The second if stement is run when the hexadicmal
conditions is not met and the funny part is that it never ever happens. I had
to comment out the part of the first update query which tried to update the
identity column. Now my queston are
1.why is replication trying to update the identity columns when it know
that they can not be updated.
2.What is the binary hexadecimal field used for, why is this the condition
in each and every case select statement in every field?
Please help me with this hexadecimal paradigm
The IF statement checks to see if the PK is being updated, and if so
executes the update statement differently. This is not related to identity
columns. If you have an identity column on the subscriber, compilation of
this procedure may fail. That's because the identity attribute shouldn't be
there - it's implicitly treated as read-only. If you had queued updating
subscribers the logic in these sps is different and there is no update or
insert into the identity columns because the identity attribute is expected
on the subscriber.
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
Labels:
columns,
condition,
database,
hexadecimal,
identity,
keys,
microsoft,
mysql,
mytables,
oracle,
primary,
replication,
server,
sql,
transactional
Subscribe to:
Posts (Atom)