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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...I need a member listI need a member list
Previous
 
Next
New Post
7/28/2009 5:34 AM
 

Hello,

Could somebody help me to transform my query above with using pivot because I'm bad in sql and it's not working. I'm not finding the solution... if somebody can help it will be great.... thanks a lot

 
New Post
7/28/2009 10:29 AM
 

I think I understand what you want with all the data in a single row.  I needed this to display a company directory.  What I did was created a new table with all the fields I wanted  to display.  Then I wrote a stored procedure that I run on a schedule.  The procedure first deletes all the data, then inserts records from the Users table, then runs multiple update statements from UserProfile table to get all the field I want from there.  This puts everything in one spot to easily display in a data grid.  I also did this because I used it to update login information in another application.  Procedure is below (with no guarantees).  You will of course have to build the table and modify for your situation, custom fields and property values.  Hope this helps.  Just one option.

SET

ANSI_NULLS ON QUOTED_IDENTIFIER ON procedure [dbo].[z_Update_User_Directory]

AS

BEGIN

DELETE

TRANSACTION FROM [dbo].[z_User_Directory]

INSERT

INTO [dbo].[z_User_Directory]

SELECT

[UserId]

 

 

 

 

, [FirstName], [LastName], [Email], null --Update statements below

 

, null --fill in the nulls

 

, null

 

, null

 

, null

 

, null

 

, null

 

, null

 

 

 

, [Username], [DisplayName]

FROM

[dbo].[Users]

WHERE

[UserID] > 2 AND [FirstName] <> 'TEST'

ORDER

BY LastName

UPDATE

[dbo].[z_User_Directory]

SET

[CITY] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

 

[UP].[PropertyDefinitionID] = 39

UPDATE

[dbo].[z_User_Directory]

SET

[BusinessUnit] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 40

UPDATE

[dbo].[z_User_Directory]

SET

[Department] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 44

UPDATE

[dbo].[z_User_Directory]

SET

[Position] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 43

UPDATE

[dbo].[z_User_Directory]

SET

[Phone] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 31

UPDATE

[dbo].[z_User_Directory]

SET

[Extension] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 42

UPDATE

[dbo].[z_User_Directory]

SET

[Mobile] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 32

UPDATE

[dbo].[z_User_Directory]

SET

[FAX] = [UP].[PropertyValue]

FROM

 

 

[dbo].[z_User_Directory] U INNER JOIN [dbo].[UserProfile] UP ON [U].[UserID] = [UP].[UserID]

WHERE

[UP].[PropertyDefinitionID] = 33

IF

 

ELSE

@@ERROR = 0 COMMIT TRANSACTION

 

ROLLBACK TRANSACTION

 

GO

SET

GO

ALTER

 
New Post
7/28/2009 12:53 PM
 

Tim Wimmer wrote
 

I think I understand what you want with all the data in a single row.  I needed this to display a company directory.  What I did was created a new table with all the fields I wanted  to display.  Then I wrote a stored procedure that I run on a schedule.  The procedure first deletes all the data, then inserts records from the Users table, then runs multiple update statements from UserProfile table to get all the field I want from there.  This puts everything in one spot to easily display in a data grid.  I also did this because I used it to update login information in another application.  Procedure is below (with no guarantees).  You will of course have to build the table and modify for your situation, custom fields and property values.  Hope this helps.  Just one option.

 Sorry, the code didn't format very well when pasted in.  If you want  to send me your email to wtim1@yahoo.com I could send it to you in a text file.

 

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...I need a member listI need a member list


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