首頁 > 資料庫 > mysql教程 > Get Profile Property List By UserID

Get Profile Property List By UserID

WBOY
發布: 2016-06-07 14:57:21
原創
1252 人瀏覽過

没什么大用处 无 CREATE FUNCTION GetProfilePropertyList(@userID uniqueidentifier)RETURNS @propertyTable TABLE(PropertyName varchar(250),PropertyValue varchar(250))BEGINDECLARE @count int = 0DECLARE @pName varchar(250)DECLARE @pStartIndex int

没什么大用处
CREATE FUNCTION GetProfilePropertyList
(
	@userID uniqueidentifier
)
RETURNS 
@propertyTable TABLE
(
	PropertyName varchar(250),
	PropertyValue varchar(250)
)
BEGIN
	DECLARE @count int = 0
	DECLARE @pName varchar(250)
	DECLARE @pStartIndex int
	DECLARE @pLen int
	
	DECLARE @propertyNames varchar(1000)
	DECLARE @propertyValues varchar(1000)
	
	SELECT @propertyNames = PropertyNames,
		   @propertyValues = PropertyValuesString
	From aspnet_Profile
	Where UserId = @userID
	
	WHILE(LEN(@propertyNames) > 0)
	BEGIN
		DECLARE @index int
		DECLARE @prop varchar(250)
		SELECT @index = CHARINDEX(':', @propertyNames)
		SELECT @prop = SUBSTRING(@propertyNames, 0, @index)
	 
		SELECT @propertyNames = SUBSTRING(@propertyNames, @index + 1, LEN(@propertyNames))
		
		SELECT @count = @count + 1
		IF(@count % 4 = 1) SELECT @pName = @prop
		IF(@count % 4 = 3) SELECT @pStartIndex = CAST(@prop AS INT)
		IF(@count % 4 = 0) 
		BEGIN
			SELECT @pLen =  CAST(@prop AS INT)
			INSERT INTO @propertyTable VALUES (@pName, SUBSTRING(@propertyValues, @pStartIndex + 1, @pLen))
		END
				
	END
END
 
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板