Iggy Kay


Hi,

anyone knows if there's an easy way to insert new GUIDs into uniqueidentifier cells when editing data in table on Management Studio Express or Visual Studio 2005 Server Explorer I can't find a shortcut, and copying from external tools is pain..

I suppose it's possible to build a VB macro in Visual Studio, would it work when editing table data

Thanks in advance!



Re: Shortcut to insert new GUID into uniqueidentifier cell in MSSQL Management Studio Express?

Mike Hildner


I don't know if there's a shortcut, but you can set the default value of the column to newid(), then you don't have to type anything in. Does that work for you

Mike






Re: Shortcut to insert new GUID into uniqueidentifier cell in MSSQL Management Studio Express?

LearnSqlServer.com

Mike's advice is the best. AFAIK there's no shortcut to inserting a GUID using the GUI tools...

/****************************************************

Check out our Sql Server 2005 and 2000 tutorials

****************************************************/







Re: Shortcut to insert new GUID into uniqueidentifier cell in MSSQL Management Studio Express?

Martin Smith

It's a pain in the arse without this. You can't copy a row from elsewhere in the table as you can for normal IDENTITY columns it will copy the Guid as well. If you then delete the GUID and leave an empty string it will tell you it's not a valid GUID format. If you press CTRL + 0 to make the cell null it will tell you the cell doesn't allow nulls. I could always just alter a random few characters in the GUID but I suspect that will greatly increase my chance of collisions...




Re: Shortcut to insert new GUID into uniqueidentifier cell in MSSQL Management Studio Express?

Martin Smith

Actually I've found a way round it. Just don't include the GUID column with the NEWID default in the select when copying and pasting rows and all works well.





Re: Shortcut to insert new GUID into uniqueidentifier cell in MSSQL Management Studio Express?

Kent Waldrop Au07

Also keep in mind that GUIDS are great for when you really need them; however, GUIDS definitely add drag to performance and it is best to use an alternative to a GUID -- such as an identity column -- whenever you can.