Help Wanted Msaccess PIVOT-query --&> MS-SQL View/sp
Jan 18, 2006
Can someone help me parsing this ms-access PIVOT sql-statement to a
ms-sql-server sql-statement?
Many thanks in advance
TRANSFORM Count(KlantenStops.id) AS AantalVanid
SELECT KlantenStops.Uitvoerder, KlantenStops.Klant
FROM KlantenStops
GROUP BY KlantenStops.Uitvoerder, KlantenStops.Klant
PIVOT DatePart("m",leverdatum,1,0) In
("1","2","3","4","5","6","7","8","9","10","11","12");
I am trying to show images in a product listing in power view.I work with an excel 2013 desktop version based on an office 365 pro account.I did the following steps:
import of an excel file with an article list via power query and loading the data to the data model import jpg images from a folder via power query, setting content as binary type and loading the data to the data modellinking both tables in power pivot--> manage via the image namesetting the table behavior for the images table under power pivot --> manage --> Advanced (e.g. Default Image: Content)opening power view and building article cards with article number and imageProblem: only a camera icon shows up in power view
Is there a solution with a desktop version?Can I use my Office 365 Pro account to make it work? How?Why is there no solution showing images in a pivot table?Link to Dropbox with power pivot filesÂ
I have one UDF which take 5 params. When I run this UDF from Query Analyzer (select * from dbo.UDFname (param1, ..., param5)), it take 5 seconds, but when I run from ADP project (doble click), it take > 200 seconds. In both situations I obtain the same result (of course). I look at the connexion, seems ok (File -> Connexion; in .adp).
Can anybody tell me why are this differences? And how to surpass this ? I want to use the access .adp to make one front to run a MSDE db.
I have one UDF which take 5 params. When I run this UDF from Query Analyzer, it take 5 seconds, but when I run from ADP project (doble click), it take > 200 seconds. I look at the connexion, but I don't see nothing to change (File -> Connexion; in .adp).
I'm converting an ASP system from using msaccess to SQL Server as the db engine, and I'm stumped on the following query
update timecard set TcdDate = #3/18/05#
TcdDate is defined as a date/time type
It will not run with the date bracketed by # signs, and when I take them out, 1/1/1900 is stored in the dbs. Is there a different symbol to bracket the date with or should I be using a function to convert the date?
Hi all,is there any tool which is capable to convert query initially written formsaccess database to query for mssql server.I have tons of queries which contains iif, trim and similar functions whichshould be converted to case, ltrim(rtrim(, etc. etc.Does anyone know for tool which could do that automatically?Thanks in advance,Anabella
(sorry, I don't know how to make the copied tables 'look right' but spaces should --> tabs) Branches Table B_ID Branch 0 OLD 1 ADM 2 CL1 3 CL2 4 NEB 5 PTO 6 HOL 9 MKT 10 CL3 12 IOW 15 IND 16 PAP 18 SOU 19 NOR Value Table (Pk = Vid, FK = Bid) VID BID Emp_id Value 1 4 1 100 2 4 1 200 3 10 1 300 4 3 2 400 5 4 2 500 6 4 2 600
Desired Result View (Pivot on On Emp_id sum the value column) Emp_ID OLD ADM CL1 CL2 NEB PTO HOL MKT CL3 IOW IND PAP SOU NOR 1 0 0 0 0 300 0 0 0 0 0 300 0 0 0 2 0 0 0 400 1100 0 0 0 0 0 0 0 0 0
My current solution is to use a pivot query similar to the below (note: ..etc. used to simplify the discussion), It gets me close with the exception of presenting the null values as null rather than 0, I can make that work! SELECT Emp_id,[0] AS OLD, [1] AS AD, [2] AS CL1, [3] AS CL2, [4] AS NEB ....etc) FROM (SELECT Emp_id, value, B_id FROM Branches) P PIVOT (sum(value) FOR B_idId IN ([0], [1], [2], [3], [4].."etc.")) AS pvt "Take the data from the Branches table, sum up the values for a employee then present as a "pivoted" sql view with each branch in a column and nulls converted to 0"
Finally here is the problem/question.
I don't want to 'hard' code the branches (as the solution above does), they will change over time as branches are added and I want the query to reflect these changes. The problem, I don't know how to proceed from here, I have looked at using a SSAS solution, but that seems like too much for such a simple problem and in any case, I don't know how to integrate the SSAS cube into the current Ms Access 2000 solution (moving from Access backend data store to SQL server 2005).
Note: all the examples I have found in the BOL and forums, hard code the columns
I am frankly overwhelmed be the number of options available in SQL Server 2005, and still am trying to 'get my mind' around some of the concepts. I'm sure I don't know many of the options available, much more how to best implement them. The BOL, while good, have not really provided the enlightment I seek.
If I have to go to a CLR solution, could one provide some simple guidance, Thanks.
I would like to have rows presented as columns. That's why I use the PIVOT function at the end.The resultset will be presented in Excel using an external connection to the view.
When I try to save the view I get the error
Msg 4104, Level 16, State 1, Procedure _TEST, Line 47
The multi-part identifier "vk.OppCode" could not be bound.
Code (restricting the columns that I actually have to the relevant columns only):
USE [DBTest] GO /****** Object: View [dbo].[_TEST] Script Date: 23-10-2014 17:24:10 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON
Using PowerPivot I created a connection to a view on a SQL Server database. All fields imported correctly.A column has since been added to the view. How do I get this to appear in my PowerPivot?
I am looking for a way to create a stored procedure that will show inventory availability. I would like to show the Inventory Name, The Date, and if the inventory is "checked out" using the ID name of the person who has the item.
For example it would look like this:
-------------------------------------------------------------------------------------------------- Inventory Name | 10/24/2015 | 10/25/2015 | 10/26/2015 | 10/27/2015 | 10/28/2015 -------------------------------------------------------------------------------------------------- Laptop | Tom | Tom | Tom | Avail | Avail Projector | Avail | Avail | Avail | Avail | Bob Air Card | Bob | Bob | Bob | Bob | Bob
It seems like I want to do a pivot table but there really is no aggregate so I am not sure what to use.
I would like to use a dynamic pivot table in my data source view. It seems that a named query can be only one sql statement. So, I cannot use my multi-statement procedure that creates a dynamic pivot table output.
What is the best course of action here? I could hard-code my pivot table query. I could maintain a redundant table in the pivot format. Do I have any good options?
When ever I create a new Powerpivot from an AS cube, PowerPivot shows the data only in flattened PowerPivot format. How can I get back to traditional hierarchy dimensional view in Pivot table.
I have written a script to pivot a table into multiple columns.
The script works when run on its own but gives an error when i try to create a view or aprocedure from the same script. The temporary table #.... does not work so i have converted it to a cte.
Here is a copy of the script below
-- Dynamic PIVOT IF OBJECT_ID('#External_Referrals') IS NULL DROP TABLE #External_Referrals; GO DECLARE @T AS TABLE(y INT NOT NULL PRIMARY KEY);
I compared view query plan with query plan if I run the same statementfrom view definition and get different results. View plan is moreexpensive and runs longer. View contains 4 inner joins, statisticsupdated for all tables. Any ideas?
I have several reports in a Power View Gallery. In Gallery view, most of the reports show the "Open New Excel Workbook", the "Create Power View Report", and the "Manage Data Refresh" buttons on the right side of the report list. Why would some reports not have these buttons available? In the attached image you can see one report with the buttons and one without the buttons.
I'm a relative newcomer to Power View. I've been playing with charts and have been struggling to combine both line and bar on the same chart. It would appear this functionality is not available. Considering this is basic functionality when it comes to charting, how to achieve this....
consider the following table: name , TaskDate john , 01/01/2006 john , 01/03/2005 steve , 01/05/2006 i want to build a select statement that gives result like the following: name , JanuaryTotal , FebruaryTotal john , 150 , 110 steve , 170 , 50 so the result will be total tasks in specific month, is it doable in one select or should i turn around using hash tables ???
Ok guys I have read everything in my previous post but unfortunately can not seem to get it to work properly. Would anyone like to do this 10 minutes work (I am sure). Obviously I dont expect it to be free but if I continue I am going to get a sledge hammer to this now.
Hi, I have the following query that kinda does what i want
SELECT ABTANumber, TourOperator, ReportStatus, COUNT(*) AS Counter FROM (SELECT ABTANumber, TourOperator, r.ReportStatus FROM bookingdetails bd LEFT JOIN report r ON bd.Id = r.BookingDetailsId) a GROUP BY ABTANumber, TourOperator, ReportStatus
SELECT [R].[PaymentMonth], [S].[RegionCode], [S].[CmsStateShortName], [P].[Attribute1] AS [FinalProduct], [Membership] = SUM([R].[Membership])
FROM [RptMMRSummary1] [R] INNER JOIN [RefCmsState1] [S] ON [R].[CmsStateCode] = [S].[CmsStateCode] INNER JOIN [RefPlanBenefitPackage1] [P] ON [R].[PlanBenefitPackageID] = [P].[PlanBenefitPackageID] WHERE [R].[PaymentMonth] IN ('200712', '200711', '200612') -- [P].[Attribute1] IN ('HMO', 'PPO', 'PFFS', 'SNP', 'EVCSNP') GROUP BY [R].[PaymentMonth], [S].[RegionCode], [S].[CmsStateShortName], [P].[Attribute1] ------------------------------------------------------------------- How do we use the pivot query for the above script. Layout as below
200801 Month / Year Selection
------------------------------------------------------- StateShortname | Attribute | Attribute | Attribute | Total ---------------------------------------------------------- AL Values Values Values OL Values Values Values ZW Values Values Values WEST Group By Region Code Total BK Values Values Values MN Values Values Values EAST Group By Region Code Total
200712 Always Previous Month for the above selection Month /Year
------------------------------------------------------- StateShortname | Attribute | Attribute | Attribute | Total ---------------------------------------------------------- AL Values Values Values OL Values Values Values ZW Values Values Values WEST Group By Region Code Total BK Values Values Values MN Values Values Values EAST Group By Region Code Total
200612 Always Previous year End Month for the above select Month / Year
------------------------------------------------------- StateShortname | Attribute | Attribute | Attribute | Total ---------------------------------------------------------- AL Values Values Values OL Values Values Values ZW Values Values Values WEST Group By Region Code Total BK Values Values Values MN Values Values Values EAST Group By Region Code Total
I would like to have it in the following format ======================================================== unitid CCT1 CCT2 CCT3 CCT4 ---------------------------------------------------------------------------------------------------------------- 1 Ravi,Raja,Kanna Senthil,Lee,Suresh 2 John,Vijay,Nithya Ram,Krish,Latha Raja,Vijay,Ram Sankar
Hi, does somebody recognize the problem with my code? -Thanks! Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: This is an unexpected token. The expected token is 'NAME'. Line 58, position 52.Source Error: <sessionState mode="SQLServer"stateConnectionString="Jensen"sqlConnectionString= "datasource=Database;userid=username;password=pass"cookieless="false"timeout="60"/>
Always looking for people who are strong with microsoft technology for new oppurtunities in the Seattle area. If you are good, we can help you find your ideal next position.
I am looking for strong SQL developers and/or DBA's for some really sweet companies here in Seattle. Anyone interested that is good and wants to hear about new oppurtunities? I would love to help you out.
In the First DELETE and bcp I was getting the thread being launched by xp_cmdshell was being blocked by the parent thread...
put in WAITFOR...sometime it worked...started with an empty table..it worked....left the 28k rows, blocked...
Now, put SELECT COUNT(*)...works each and every g-d damn time...
HUH?
Now I get to the bcp out..
added the same code WAITFOR/SELECT *...
blocks each and ever g-d damn time....
I'm very reticent to COMMIT and start another tranny block...
Anyone have any ideas?
SET NOCOUNT ON
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[wrk_DataHold]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[wrk_DataHold] GO
CREATE TABLE wrk_DataHold(Col1 varchar(8000)) GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[wrk_OldNew]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[wrk_OldNew] GO
CREATE TABLE wrk_OldNew(Old varchar(255),New varchar(255)) GO
INSERT INTO wrk_OldNew(Old,New) SELECT 'SEVERAL EE~S', '' GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_ModifyRows]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[usp_ModifyRows] GO CREATE PROC usp_ModifyRows @Path sysname , @FName sysname AS
SET NOCOUNT ON
BEGIN TRAN
DECLARE @cmd varchar(8000), @Servername sysname, @rc int, @error int, @rowcount int , @Old varchar(255), @New varchar(255), @x int
CREATE TABLE #bcpLog(Col1 varchar(8000))
SET @rc = 0
DELETE FROM wrk_DataHold
SELECT @error = @@error, @rowcount = @@ROWCOUNT IF @error <> 0 BEGIN SET @rc = -1 GOTO usp_ModifyRows_Error END
SELECT @x=COUNT(*) FROM wrk_DataHold WAITFOR DELAY '000:00:10'
SET @cmd = 'bcp wrk_DataHold in ' + @Path + @FName + ' -S ' + @@SERVERNAME + ' -U -P -c' INSERT INTO #bcpLog(Col1) EXEC master..xp_cmdShell @cmd
DECLARE OldNew CURSOR FOR SELECT Old, New FROM wrk_OldNew
OPEN OldNew
FETCH NEXT FROM OldNew INTO @Old, @New
WHILE @@FETCH_STATUS = 0 BEGIN
UPDATE wrk_DataHold SET Col1 = REPLACE(Col1,@Old,@New) WHERE Col1 LIKE '%'+@Old+'%'
SELECT @error = @@error, @rowcount = @@ROWCOUNT IF @error <> 0 BEGIN SET @rc = -1 GOTO usp_ModifyRows_Error END
INSERT INTO #bcpLog(Col1) SELECT 'REPLACE "'+ RTRIM(@Old) + '" With "' + RTRIM(@New)+ '"' UNION ALL SELECT '('+CONVERT(varchar(25),@rowcount)+' row(s) affected)'
FETCH NEXT FROM OldNew INTO @Old, @New END
CLOSE OldNew DEALLOCATE OldNew
SELECT @x=COUNT(*) FROM wrk_DataHold WAITFOR DELAY '000:00:10'