ms-query

Alternative to Left Join

倾然丶 夕夏残阳落幕 提交于 2019-12-11 01:26:29
问题 I need to display the monthly rates for a fixed set of pipelines in Excel 2007 using MS Query and even if a pipeline has no monthly rate it has to be displayed in this manner I have done it using the following code in SQL Server 2008 R2. SELECT P.Name AS [Pipeline Name], PR.Id, PR.[Name], PH.[Value] AS Rate FROM [GAS].[dbo].[Pipelinerate] PR INNER JOIN Pipeline P ON P.Id = PR.Pipelineid LEFT OUTER JOIN [GAS].[dbo].[Pipelineratehistory] PH ON PH.[Pipelinerateid] = PR.[Id] AND ( PH.[Month] = ?

How to create copy of database using backup and restore

半城伤御伤魂 提交于 2019-12-08 11:15:14
问题 Using SQL Server Management Studio 2012, I'm trying to create a copy of a local database. I found a few variants of solution. One of them - backup and restore database as new one - HERE. Currently create database backup with name Rewards2_bak . This copy of file place in to system catalog C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\ Next step - create query for restoring database as copy of existing one GO use master RESTORE FILELISTONLY FROM Rewards2_bak RESTORE

Could not add the table (

那年仲夏 提交于 2019-12-02 07:37:36
问题 The following code works in Sage200. SELECT bcs.BomReference ,bcs.DateTimeCosted ,bcs.TotalCost FROM ( SELECT BomReference ,Max(DateTimeCosted) AS MaxDate FROM NDM_Sage200.dbo.BomCostSession BomCostSession GROUP BY BomReference ) AS ldc INNER JOIN BomCostSession AS bcs ON bcs.BomReference = ldc.BomReference AND bcs.DateTimeCosted = ldc.MaxDate ORDER BY BomReference As soon as I try extending this with an INNER JOIN to another table to get more columns (using BomReference ), I get the error

Could not add the table (

亡梦爱人 提交于 2019-12-02 03:51:18
The following code works in Sage200. SELECT bcs.BomReference ,bcs.DateTimeCosted ,bcs.TotalCost FROM ( SELECT BomReference ,Max(DateTimeCosted) AS MaxDate FROM NDM_Sage200.dbo.BomCostSession BomCostSession GROUP BY BomReference ) AS ldc INNER JOIN BomCostSession AS bcs ON bcs.BomReference = ldc.BomReference AND bcs.DateTimeCosted = ldc.MaxDate ORDER BY BomReference As soon as I try extending this with an INNER JOIN to another table to get more columns (using BomReference ), I get the error message: Could not add the table ( . See below for example of modified code; I have to use 2 joins to get

How to add parameters to an external data query in Excel which can't be displayed graphically?

你说的曾经没有我的故事 提交于 2019-11-27 06:34:01
I often use MS Excel's Get External Data to create simple reports - running queries against databases and displaying nicely in Excel. Excel's great features like filtering and pivot tables and familiar interface for users make it quite good for this. However, one limitation with Microsoft Query is you can't add parameters to queries that can't be displayed graphically, which considerably limits the SQL you can write. Is there any solution to the error "parameters are not allowed in queries that can't be displayed graphically"? Excel's interface for SQL Server queries will not let you have a

How to add parameters to an external data query in Excel which can't be displayed graphically?

自作多情 提交于 2019-11-26 10:25:34
问题 I often use MS Excel\'s Get External Data to create simple reports - running queries against databases and displaying nicely in Excel. Excel\'s great features like filtering and pivot tables and familiar interface for users make it quite good for this. However, one limitation with Microsoft Query is you can\'t add parameters to queries that can\'t be displayed graphically, which considerably limits the SQL you can write. Is there any solution to the error \"parameters are not allowed in