any idea how I can get user FirstName and LastName from the aspnet_profile table based on UserID using SQL becasue I would like to use in Telerik Reporting as a user parameter.
Sample row (FirstName is George, LastName is Test):
UserID: 06b24b5c-9aa1-426e-b7e4-0771c5f85e85
PropertyName: MobilePhone:S:0:0:Initials:S:0:1:City:S:1:14:FirstName:S:15:6:PostalCode:S:21:7:WorkPhone:S:28:12:LastName:S:40:5:Address1:S:45:17:Address2:S:62:0:Province:S:62:2:Organization:S:64:4:ClinicId:S:68:1:Country:S:69:6:Fax:S:75:0:MSPNumber:S:75:0:
PropertyValuesString: HEast HustonEASGeorgeT7D 1N8604-111-2222Test5555 Beddtvue AveDCHCNL2Canada
PropertyValuesBinary: <Binary data>
LastUpdateDate: 2010-01-02 22:22:03.947
http://www.karpach.com/Get-asp-net-profile-value-MS-SQL-database-using-T-SQL.htm
this helped me tremendously!
following the steps in that link allowed me to fetch any particular data in the PropertyValueString from the aspnet_profile table.
copying and pasting- First Function:
Second Function:
SQL Query can be modded to your needs
For those who are still looking for a method to parse the aspnet_Profile table using pure SQL. Here is what I use:
First you need a Tally table. If you do not know what this is, read this article by Jeff Moden: http://www.sqlservercentral.com/articles/T-SQL/62867/
For you to generate the tally table use this script:
Now on to parsing the ProfileData: The process below is the fastest way I found to do this after lots of testing on my specific data. I have tested parsing the complete table in one go, but that runs slower than using the function below and parsing one user at a time with a CROSS APPLY.
So to call the function, use something like:
The only thing you need to do is to update 3 things to contain the Profile Properties that you use: 1) the return table 2) the PIVOT statement, and 3) the insert statement copying the data from the PIVOT into the return table
Here is the function, Enjoy!
If you insist on using SQL, I'm sure a large number of SUBSTRINGs and PATINDEXes will get you there but it won't be a clean solution.
Update: user373721 found a great resource and posted a comment about it, but it can be easily missed, so I decided to add it to the answer, too - How to get asp.net profile value from MS SQL database using T-SQL?
The built-in
dbo.aspnet_Profile_GetProperties
stored procedure returns thePropertyValuesString
value that is later parsed in theParseDataFromDB
function.