SQL aspnet_profile
知道如何使用 SQL 从基于 UserID 的 aspnet_profile 表中获取用户名字和姓氏,因为我想在 Telerik Reporting 中使用作为用户参数。
示例行(名字是 George,姓氏是 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你坚持使用 SQL,我确信有大量 SUBSTRINGs 和 PATINDEXes 可以帮助您实现这一目标,但它不是一个干净的解决方案。
更新: user373721 找到了一个很棒的资源并发表了评论,但它可以很容易地错过了,所以我决定也将其添加到答案中 - 如何获取 asp.net使用 T-SQL 从 MS SQL 数据库获取配置文件值?
内置
dbo.aspnet_Profile_GetProperties
存储过程返回稍后在 ParseDataFromDB 中解析的PropertyValuesString
值功能。
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.
http://www .karpach.com/Get-asp-net-profile-value-MS-SQL-database-using-T-SQL.htm
这对我帮助很大!
按照该链接中的步骤,我可以从 aspnet_profile 表中获取 PropertyValueString 中的任何特定数据。
复制和粘贴-
第一个功能:
第二个功能:
SQL 查询可以根据您的需要进行修改
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
对于那些仍在寻找使用纯 SQL 解析 aspnet_Profile 表的方法的人。这是我使用的:
首先你需要一个理货表。如果您不知道这是什么,请阅读 Jeff Moden 的这篇文章: http:// www.sqlservercentral.com/articles/T-SQL/62867/
要生成统计表,请使用以下脚本:
现在开始解析 ProfileData:
在对我的特定数据进行大量测试后,我发现以下过程是最快的方法。我已经测试过一次性解析整个表,但这比使用下面的函数并使用 CROSS APPLY 一次解析一个用户要慢。
因此,要调用该函数,请使用以下内容:
您唯一需要做的就是更新 3 个内容以包含您使用的配置文件属性:
1)返回表
2) PIVOT 语句,以及
3) insert 语句将数据从 PIVOT 复制到返回表
这是该函数,享受吧!
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!