guid

How to INSERT into a table that uses sequential GUIDs as a primary key?

三世轮回 提交于 2019-12-23 09:01:28
问题 Here is a simplified version of the table I am looking at: CREATE TABLE [dbo].[FrustratingTable] ( [Id] Uniqueidentifier NOT NULL , [SecondField] [datetime] , [ThirdField] varchar(128) ) I want to insert new records into this table. I have tried 3 approaches: INSERT INTO [dbo].[FrustratingTable] (Id, SecondField, ThirdField) SELECT newid() as Id, '6/25/2015' as SecondField, 'Example' as ThirdField This approach inserts, but the resulting key isn't a nice sequential GUID like the other ones in

rename each file with new-guid in powershell

天涯浪子 提交于 2019-12-22 12:45:10
问题 I have been trying to rename each txt file in a folder with the filename $New-Guid .txt, so they should all have unique names. Anyone know the simple way to do this? 回答1: tl;dr Get-ChildItem ... | Rename-Item -NewName { "$(New-Guid).txt" } Note the use of a script block ( { ... } ) and the call to New-Guid inside $(...) embedded in an expandable string ("..."). File renaming / moving operations with multiple input files are most efficiently performed with delay-bind script blocks , where a

What is the smallest way to store a UUID that is human readable?

吃可爱长大的小学妹 提交于 2019-12-22 10:29:57
问题 What is the smallest way to store a UUID that is human readable and widely database compatible? I am thinking a char array of some sort using hex values? 回答1: As common approach, i think that encoding the binary data (16 bytes) as Base64 could be what you want. 回答2: Use Base-85 encoding to store the UUID as 20 US-ASCII characters. 回答3: You might find the latest podcast relevant: http://itc.conversationsnetwork.org/shows/detail4087.html Database-wide unique-yet-simple identifiers in SQL Server

Manual change of GUID - how bad is it?

£可爱£侵袭症+ 提交于 2019-12-22 09:48:37
问题 How bad is changing generated GUID manually and using it? Is the probability of collision still insignificant or is manipulation with GUIDs dangerous? Sometimes we just change some letter of previously generated GUID and use it. Should we stop doing it? 回答1: This depends on the version of the GUID and where you are making the change. Let's dissect a little how a GUID actually looks like: A GUID has a version.   The 13th hex digit in a GUID marks its version. Current GUIDs are usually

How do I escape curly braces {…} in powershell?

蹲街弑〆低调 提交于 2019-12-22 08:26:29
问题 I need to generate multiple lines of xml tag with a GUID in them: <xmltag_10 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> <xmltag_11 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> and so on I have this line in a loop where $guid is generated each iteration, and it prints the guid without surrounding braces Write-Host ('<xmltag_{0} value="{1}"/>' -f $i,$guid) <xmltag_10 value="ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ"/> Adding a set of curly braces, I get Write-Host ('<xmltag_{0} value="{{1}

MySQL - autoincrement to guid

怎甘沉沦 提交于 2019-12-22 06:47:48
问题 I have a table with an auto-increment ID field as shown below. +------------+-------------------------------------+ | company_id | name | +------------+-------------------------------------+ | 1 | International Client | | 2 | Oracle | | 3 | test | | 4 | testabc | | 5 | testdef | | 6 | abcd | +------------+-------------------------------------+ I want to update the ID column to be a GUID using the uuid() function. Additionally, how do I update the foreign key references to the correct GUID?

How predictable is NEWSEQUENTIALID?

假如想象 提交于 2019-12-22 06:35:49
问题 According to Microsoft's documentation on NEWSEQUENTIALID, the output of NEWSEQUENTIALID is predictable. But how predictable is predictable? Say I have a GUID that was generated by NEWSEQUENTIALID , how hard would it be to: Calculate the next value? Calculate the previous value? Calculate the first value? Calculate the first value, even without knowing any GUID's at all? Calculate the amount of rows? E.g. when using integers, /order?id=842 tells me that there are 842 orders in the application

How can I generate a Guid from a SHA-1 byte array?

匆匆过客 提交于 2019-12-22 05:33:25
问题 I have this code to generate a SHA-1 hash: SHA1 sha1 = SHA1CryptoServiceProvider.Create(); Byte[] myStringBytes = ASCIIEncoding.Default.GetBytes(myString); Byte[] hash = sha1.ComputeHash(myStringBytes); Is there a way to turn hash into a Guid (type 5, I guess, to be consistent with SHA-1)? 回答1: You could use this C# code based on rfc4122. To prevent link rot, some code here: public static Guid Create(Guid namespaceId, string name) { if (name == null) throw new ArgumentNullException("name"); /

How can I create a guid in MFC

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 03:53:24
问题 I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use? 回答1: GUID guid; HRESULT hr = CoCreateGuid(&guid); // Convert the GUID to a string _TUCHAR * guidStr; UuidToString(&guid, &guidStr); The application is responsible for calling RpcStringFree to deallocate the memory allocated for the string returned in the StringUuid parameter. 回答2: //don't forget to add

Creating a Globally Unique Android Identifier

情到浓时终转凉″ 提交于 2019-12-21 13:36:09
问题 When talking about unique Android ID's, I'm sure everyone has seen this, however I too am trying to come up with a solution to uniquely identify any android device. I would be happy to use a publicly released class but I am yet to find one. In my situation, the requirement is to be able to uniquely identify any devices that have some form of an internet connection (such as GPRS or Wi-Fi) and run on API level 8 (v2.2 Froyo). I'm not aware of any devices that doesn't have Wi-Fi or a SIM so let