dynamic-pivot

Help needed with Dynamic Pivoting in SQL2005

I have a table of name value pairs where I am storing tags: TAGID | NAME | VALUE I have a table of 'Things' this tags apply to THINGID | TAGID I need a query to generate a resultSet were the columns/fields are all possible TAG-NAMES (NAME field in the TAG table)for a given THINGID and the values are the correspondent tag values. T...

How to generate Pivot table in ExcelSheet Programatically

I am required to generate a Pivot table in MS Excel(not in Open Office) dynamically as per the User's query. I am programing in java and MySql(DB),so cant use the windows or MS object directly that's why wana to use VbScript . This vbscript will contain data as well as orentation on the columns in Pivot fieldList .But can any body tell m...

SQL Dynamic Pivot - how to order columns

I'm working on a dynamic pivot query on a table that contains: OID - OrderID Size - size of the product BucketNum - the order that the sizes should go quantity - how many ordered The size column contains different sizes depending upon the OID. So, using the code found here, I put this together: DECLARE @listCol VARCHAR(2000) DE...

SQL Server - Dynamic PIVOT Table - SQL Injection

Sorry for the long question but this contains all the SQL I've used to test the scenario to hopefully make it clear as to what I'm doing. I'm build up some dynamic SQL to produce a PIVOT table in SQL Server 2005. Below is code to do this. With various selects showing the raw data the values using GROUP BY and the values in a PIVOT as I...

How do I pivot dynamically

I have two tables; Leads, Territories and Referrers. Lead has columns: ID, Name, TerritoryId Referrers has: ID, LeadId, Name Territory has: ID and Name A lead always relates to a territory and a lead can optionally relate to a Referrer. Leads and Referrer records are regularly inserted (Referrers less frequently). I want to outpu...

Pivoting a table in SQL Server 2005 to contain same column multiple times

I need to pivot the following table named tblGameRoleName - Game Role Name VolleyBall Coach Sujatha VolleyBall Player Rajendran VolleyBall Player Juno VolleyBall Player Indira VolleyBall Player Ganesh VolleyBall Player Vasanth Tennis Coach Rajeshkumar Tennis Player Vivek Tennis Player Rubala ...

How to use PIVOT in SQL Server 2005 Stored Procedure Joining Two Views

Good Morning, I have 2 views: ICCUDays which contains one record per account with fields ACCOUNT and ICCUDays, ICCUEnctrSelectedRevCatsDirCost which contains multiple records per account with fields ACCOUNT, UBCATEGORY, and DirectCost. My Goal: To create a stored procedure that outputs one record per ACCOUNT with ICCUDays and DirectC...

Select row data as ColumnName and Value

I have a history table and I need to select the values from this table in ColumnName, ColumnValue form. I am using SQL Server 2008 and I wasn’t sure if I could use the PIVOT function to accomplish this. Below is a simplified example of what I need to accomplish: This is what I have: The table’s schema is CREATE TABLE TABLE1 (ID INT...

display rows as colum

I want to display rows as column in SQL Server. My table looks like this: images_id item_id images_name ------------------------------- 1 1 image1.jpg 2 1 image2.jpg 3 1 image3.jpg 4 2 image4.jpg 5 2 image5.jpg 6 2 image6.jpg I'd ...

transposing a table

Hi I would like to rotate a full table: LANGUAGE litAccept litDelete litErrorMsg .............. ------------------------------------------------- SPANISH Accept Delete Error has ocurred ENGLISH Aceptar Borrar Ha ocurrido un error ..... into something like this: LANGUAGE ENGLISH SPANISH ----------------------------...

Crosstab/Pivot query in TSQL on nvarchar columns

I have a Table1: ID Property 1 Name 2 City 3 Designation and Table2: ID RecordID Table1ID Value 1 1 1 David 2 1 2 Tokyo 3 2 1 Scott 4 2 3 Manager The Table1ID of Table2 maps to Table1's ID. Now I wish to show the Table1 Property column values as colum...