August 15, 2011 at 12:18 pm
Hi,
If I remember in MSCRM 3 and 4 the GUID your record obtain in the database have the same prefix depend of witch entity this record is coming from. Can you tell me how can I do the same thing with t-sql query.
her is a example of what I want to see
When it's a customer card
4F9796A9-5B5C-4D2B-8CCB-0D6C34C59791
4F9796A9-D064-4747-A997-A944629E9BB7
and Item Card
069A46C3-28A3-404C-8754-F84936D3DC14
069A46C3-8E20-463B-BDEB-15643CFDFAD2
069A46C3-F94F-40C6-8614-32EF470C3235
August 15, 2011 at 1:30 pm
I hope you are not using a UniqueIdentifier as your primary key. There are a zillion reasons that is not a great idea. But you can "roll your own" UniqueIdentifier if you really want to. Something like the following should show you an example of how you can do it.
declare @ID uniqueidentifier = newid()
select @ID,
SUBSTRING(cast(@ID as varchar(36)), CHARINDEX('-', @ID, 0), DATALENGTH(cast(@ID as varchar(36))))
, cast('4F9796A9' + SUBSTRING(cast(@ID as varchar(36)), CHARINDEX('-', @ID, 0), DATALENGTH(cast(@ID as varchar(36)))) as uniqueidentifier)
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 15, 2011 at 1:46 pm
Thanks SSCrazy
This is not the way I expect to see the problem to be resolved, But this will work.
I'm not the DB designer for this project, but from what I read will looking fro this answer, More I read GUID more I hate the things.
Thanks Again
Theknee
August 15, 2011 at 2:06 pm
Theknee (8/15/2011)
Thanks SSCrazyThis is not the way I expect to see the problem to be resolved, But this will work.
I'm not the DB designer for this project, but from what I read will looking fro this answer, More I read GUID more I hate the things.
Thanks Again
Theknee
Actuall my name is Sean. SSC Crazy is the "ranking" or whatever based on total posts. Yeah I would maybe create a Card table with an Identity and then a CardType column. You can imagine how painful it becomes to write queries while debugging and you have to type out guids in the where clause. YUCK!!!! :Wow: Ask your db designer to put one in a where clause and they will see how silly it is very quickly.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 15, 2011 at 2:28 pm
I'm Sorry for the mistake with your name 🙁
I will tell Him.
Thanks again.
August 15, 2011 at 2:30 pm
Theknee (8/15/2011)
I'm Sorry for the mistake with your name 🙁I will tell Him.
Thanks again.
No worries. 🙂 Happens all the time. Good luck. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply