Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...ProfilePropertyDefinition and userProfile export in sqlProfilePropertyDefinition and userProfile export in sql
Previous
 
Next
New Post
12/13/2006 12:15 PM
 

I've been looking for such a function for a long time without success. So I decided to formulate one. I am sure the sql experts will laugh at it but it works for me. Someone could improve on it by adding preliminary codes so that previous versions would be deleted before a new one is installed. For now, everything is manual. Here are the steps for using this query:

1. Select SQL from the host menu
2. Paste in the code
3. Check Run as Script
4. Click Execute
(This is done only once. Thereafter the function should be there and available)

If you did not get an error you are good to go.

Pitfalls to watch out for:

1. When calling the function you might need to call a specific 'database owner' since it may not default to dbo.
2. If you load it once even with errors, you may need to manually delete it before reloading it through SQL

I've included a sample query. Replace the xxx in xxx.jltGetProfileElement with your dbo.

CREATE FUNCTION jltGetProfileElement
(
@userID as int,
@ProfilePropertyName as nvarchar(100)
)
 RETURNS nvarchar(4000) AS
BEGIN

  -- If input is invalid, return null.
  IF  @ProfilePropertyName IS NULL
      OR LEN(@ProfilePropertyName) = 0
      OR @userID IS NULL
      OR @userID < 1
   RETURN NULL

   DECLARE @PropertyValue AS NVARCHAR(400)
   SET @PropertyValue =
      (
       SELECT UserProfile.PropertyValue
 FROM (Users INNER JOIN UserProfile ON Users.UserID = UserProfile.UserID) INNER JOIN ProfilePropertyDefinition ON UserProfile.PropertyDefinitionID = ProfilePropertyDefinition.PropertyDefinitionID
 WHERE (((Users.UserID)=@userID) AND ((ProfilePropertyDefinition.PropertyName)=@ProfilePropertyName))
      )
 
   RETURN @PropertyValue

END

 

Example:

The 2 required parameters are userID and the name of profile. The UserID is acquired from the query itself.

select userID,username,firstname,lastname,
   xxx.jltGetProfileElement(users.userID,'Street') as Street,
   xxx.jltGetProfileElement(users.userID,'City') as City,
   xxx.jltGetProfileElement(users.userID,'Region') as Region,
   xxx.jltGetProfileElement(users.userID,'PostalCode') as PostalCode
from users

 
New Post
3/31/2011 2:16 PM
 
Thanks Chris....This was exactly what i was looking for...didn't need to change anything..Thanks a ton
 
New Post
4/3/2011 3:55 AM
 
There are module that will export the data nicely into excel or .csv files.

http://www.interactivewebs.com/getlist/

This can use a role selector to build a custom list of custom profile data and export it in a file that is generated and sent via email. 

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...ProfilePropertyDefinition and userProfile export in sqlProfilePropertyDefinition and userProfile export in sql


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out