最后我得到了答案。
CREATE FUNCTION [dbo].[GetProfilePropertyValue] (
@PropertyName as varchar(max)
, @PropertyNamesString as varchar(max)
, @PropertyValuesString as varchar(max))
RETURNS varchar(max)
AS
BEGIN
DECLARE @StartIndex int
DECLARE @EndIndex int
DECLARE @StartPos int
DECLARE @Length int
-- First we find the starting position
Set @StartIndex = PatIndex('%' + @PropertyName + ':%', @PropertyNamesString) + LEN(RTRIM(@PropertyName)) + 3
Set @EndIndex = PatIndex('%:%', Right(@PropertyNamesString, LEN(@PropertyNamesString) - @StartIndex))
Set @StartPos = Cast(Substring(@PropertyNamesString, @StartIndex, @EndIndex) As Int)
-- Now we need to know how long it is
Set @StartIndex = @StartIndex + @EndIndex + 1
Set @EndIndex = PatIndex('%:%', Right(@PropertyNamesString, LEN(@PropertyNamesString) - @StartIndex))
Set @Length = Cast(Substring(@PropertyNamesString, @StartIndex, @EndIndex) As int)
-- Now we get the value we want
RETURN SUBSTRING(@PropertyValuesString, @StartPos + 1, @Length)
END
这很容易,现在我们需要做的就是运行一个获取信息的查询。
SELECT
dbo.GetProfilePropertyValue('LastName', PropertyNames, PropertyValuesString)
, dbo.GetProfilePropertyValue('FirstName', PropertyNames, PropertyValuesString)
, dbo.GetProfilePropertyValue('Phone', PropertyNames, PropertyValuesString)
FROM aspnet_Profile
加入aspnet_Users
onUserID
将为您提供用户名和电子邮件。享受。