Search Results

Search found 37012 results on 1481 pages for 'sql query'.

Page 91/1481 | < Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >

  • Stairway to T-SQL DML Level 5: The Mathematics of SQL: Part 2

    Joining tables is a crucial concept to understanding data relationships in a relational database. When you are working with your SQL Server data, you will often need to join tables to produce the results your application requires. Having a good understanding of set theory, and the mathematical operators available and how they are used to join tables will make it easier for you to retrieve the data you need from SQL Server.

    Read the article

  • We’re looking got SQL People

    - by simonsabin
    We are growing our data team at Wonga. If you are working in the SQL Server space and would like to join the one the fastest growing tech companies in Europe then please get in touch ( http://sqlblogcasts.com/blogs/simons/contact.aspx ) We have positions for production DBAs, Data QA analysts and SQL generalists (with a BI tendency). We also have generalist production support roles   Wonga is currently 3rd in the Times Tech Track 100 having been 1st last year. Being in the top 3 for two years...(read more)

    Read the article

  • SQL Server 2008 - Error starting service - model.mdf not found?!

    - by alex
    my SQL server 2008 was running fine. About an hour ago, it suddenly stopped - the MSSQLSERVER service had stopped I right clicked, clicked start, and it said the service had started, and stopped I looked in the event log and saw these two errors: 17207 : udopen: Operating system error 3(error not found) during the creation/opening of physical device C:\Program Files\Microsoft SQL Server\MSSQL\data\model.mdf. 17204 : FCB::Open failed: Could not open device C:\Program Files\Microsoft SQL Server\MSSQL\data\model.mdf for virtual device number (VDN) 1. The model.mdf db has NEVER been in that location - i specified drive F: to use for data / log during install. I checked the SQL Configuration Manager, to try and set startup params, but SQL Server is not listed as one of the services..... EDIT: I've now moved the db to where it was looking for: C:\Program Files\Microsoft SQL Server\MSSQL\data\ directory. Now if I start the service, it still does not work - i get this error message in the log: Could not find row in sysindexes for database ID 3, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes. Interestingly, i checked the error log - around the time users reported problems, there is this: 2010-01-08 17:11:26.44 spid51 Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. 2010-01-08 17:11:26.44 spid51 FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'. 2010-01-08 17:11:26.44 spid51 Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install. 2010-01-08 17:11:26.44 spid51 FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'. 2010-01-08 17:11:26.44 spid51 Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install. 2010-01-08 17:11:26.44 spid51 FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'. 2010-01-08 17:11:44.89 spid10s Service Broker manager has shut down. 2010-01-08 17:11:47.83 spid7s SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required. 2010-01-08 17:11:47.83 spid7s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

    Read the article

  • Please help me debug my SQL query.

    - by bob09
    I have a query: Select n_portions, dish_name from food_order, dish where n_portions= (select max (n_portions) FROM food_order); It's meant to return: fish pie 3 steak and chips 1 pasta bake 2 stuffed peppers 1 But i get: Pasta bake 35 Fish pie 35 Steak and chips 35 Stuffed peppers 35 Ham and rice 35 Lamb curry 35 Why is this happing? table data table data Insert into customer_order values ('00001', '03-Apr-09', '07-apr-09','St. Andrew St'); Insert into customer_order values ('00002', '05-Apr-09', '01-May-09', 'St. Andrew St'); Insert into customer_order values ('00003', '12-Apr-09', '27-Apr-09', 'Union St'); Insert into customer_order values ('00004', '12-Apr-09', '17-Apr-09', 'St. Andrew St'); Insert into Dish values ('D0001', 'Pasta bake', 'yes', '6.00'); Insert into Dish values ('D0002', 'Fish pie', 'no', '9.00'); Insert into Dish values ('D0003', 'Steak and chips', 'no', '14.00'); Insert into Dish values ('D0004', 'Stuffed peppers', 'yes', '11.50'); Insert into Dish values ('D0005', 'Ham and rice' , 'no', '7.25'); Insert into Dish values ('D0006', 'Lamb curry' , 'no', '8.50'); Insert into Drink values ('DR0001', 'Water', 'soft', '1.0'); Insert into Drink values ('DR0002', 'Coffee', 'hot', '1.70'); Insert into Drink values ('DR0003', 'Wine' , 'alcoholic', '3.00'); Insert into Drink values ('DR0004', 'Beer' , 'alcoholic', '2.30'); Insert into Drink values ('DR0005', 'Tea' , 'hot' , '1.50'); Insert into food_order values ('F000001', '000001', 'D0003', '6'); Insert into food_order values ('F000002', '000001', 'D0001', '4'); Insert into food_order values ('F000003', '000001', 'D0004', '3'); Insert into food_order values ('F000004', '000002', 'D0001', '10'); Insert into food_order values ('F000005', '000002', 'D0002', '10'); Insert into food_order values ('F000006', '000003', 'D0002', '35'); Insert into food_order values ('F000007', '000004', 'D0002', '23'); Insert into drink_order values ('D000001', '000001', 'DR0001', '13'); Insert into drink_order values ('D000002', '000001', 'DR0002', '13'); Insert into drink_order values ('D000003', '000001', 'DR0004', '13'); Insert into drink_order values ('D000004', '000002', 'DROOO1', '20'); Insert into drink_order values ('D000005', '000002', 'DR0003', '20'); Insert into drink_order values ('D000006', '000002', 'DR0004', '15'); Insert into drink_order values ('D000007', '000003', 'DR0002', '35'); Insert into drink_order values ('D000008', '000004', 'DR0001', '23'); Insert into drink_order values ('D000009', '000004', 'DR0003', '15'); Insert into drink_order values ('D0000010', '000004', 'DR0004', '15');

    Read the article

  • CTE Join query issues

    - by Lee_McIntosh
    Hi everyone, this problem has me head going round in circles at the moment and i wondering if anyone could give any pointers as to where im going wrong. Im trying to produce a SPROC that produces a dataset to be called by SSRS for graphs spanning the last 6 months. The data for example purposes uses three tables (theres more but the it wont change the issue at hand) and are as follows: tbl_ReportList: Report Site ---------------- North abc North def East bbb East ccc East ddd South poa South pob South poc South pod West xyz tbl_TicketsRaisedThisMonth: Date Site Type NoOfTickets --------------------------------------------------------- 2010-07-01 00:00:00.000 abc Support 101 2010-07-01 00:00:00.000 abc Complaint 21 2010-07-01 00:00:00.000 def Support 6 ... 2010-12-01 00:00:00.000 abc Support 93 2010-12-01 00:00:00.000 xyz Support 5 tbl_FeedBackRequests: Date Site NoOfFeedBackR ---------------------------------------------------------------- 2010-07-01 00:00:00.000 abc 101 2010-07-01 00:00:00.000 def 11 ... 2010-12-01 00:00:00.000 abc 63 2010-12-01 00:00:00.000 xyz 4 I'm using CTE's to simplify the code, which is as follows: DECLARE @ReportName VarChar(200) SET @ReportName = 'North'; WITH TicketsRaisedThisMonth AS ( SELECT [Date], Site, SUM(NoOfTickets) AS NoOfTickets FROM tbl_TicketsRaisedThisMonth WHERE [Date] >= DATEADD(mm, DATEDIFF(m,0,GETDATE())-6,0) GROUP BY [Date], Site ), FeedBackRequests AS ( SELECT [Date], Site, SUM(NoOfFeedBackR) AS NoOfFeedBackR FROM tbl_FeedBackRequests WHERE [Date] >= DATEADD(mm, DATEDIFF(m,0,GETDATE())-6,0) GROUP BY [Date], Site ), SELECT trtm.[Date] SUM(trtm.NoOfTickets) AS NoOfTickets, SUM(fbr.NoOfFeedBackR) AS NoOfFeedBackR, FROM Reports rpts LEFT OUTER JOIN TotalIncidentsDuringMonth trtm ON rpts.Site = trtm.Site LEFT OUTER JOIN LoggedComplaints fbr ON rpts.Site = fbr.Site WHERE rpts.report = @ReportName GROUP BY trtm.[Date] And the output when the sproc is pass a parameter such as 'North' to be as follows: Date NoOfTickets NoOfFeedBackR ----------------------------------------------------------------------------------- 2010-07-01 00:00:00.000 128 112 2010-08-01 00:00:00.000 <data for that month> <data for that month> 2010-09-01 00:00:00.000 <data for that month> <data for that month> 2010-10-01 00:00:00.000 <data for that month> <data for that month> 2010-11-01 00:00:00.000 <data for that month> <data for that month> 2010-12-01 00:00:00.000 122 63 The issue I'm having is that when i execute the query I'm given a repeated list of values of each month, such as 128 will repeat 6 times then another value for the next months value repeated 6 times, etc. argh!

    Read the article

  • Materialized Query Table in SQL Server 2005

    - by Azho KG
    In DB2 there is a support for Materialized Query Table (MQT). Basicly you write a query and create a MQT. But the difference from View is that the query is pre-executed and resulting data is stored in MQT and there are some options when to refresh/syncronize the MQT with base tables. I want same functionality in SQL Server. Is there a way to achieve same result? I've tables with millions of rows, and I want to show summary (like total # of members, total expense and etc) in dashboard. So I don't want to count every time user gets to dashboard, instead I want to store them in table and I want that table to be refresh each night. Any kind of hints, answers,suggestions and ideas are welcome. Thanks.

    Read the article

  • SQL Server 2008 - Search Query

    - by user208662
    Hello, I am not a SQL Expert. I’m trying to elegantly solve a query problem that others have had to have had. Surprisingly, Google is not returning anything that is helping. Basically, my application has a “search” box. This search field will allow a user to search for customers in the system. I have a table called “Customer” in my SQL Server 2008 database. This table is defined as follows: Customer UserName (nvarchar) FirstName (nvarchar) LastName (nvarchar) As you can imagine, my users will enter queries of varying cases and probably mis-spell the customer’s names regularly. How do I query my customer table and return the 25 results that are closest to their query? I have no idea how to do this ranking and consider the three fields listed in my table. Thank you!

    Read the article

  • how to create a subquery in sql using count based on outer query

    - by user1754716
    I hope someone can help me with this query. Basically I have two queries that I want to "combine". I want the second query as an extra column along with the first query. The first one is this : SELECT t_Item_Storage_Location.Storage_Loc_Nbr, t_Storage_Location.Storage_Loc_Type_Code, Count(t_Load.Load_Id) AS CurrentLoadCount, t_load.MMM_Id_Nbr FROM t_Load INNER JOIN (t_Storage_Location INNER JOIN t_Item_Storage_Location ON t_Storage_Location.Storage_Loc_Nbr = t_Item_Storage_Location.Storage_Loc_Nbr) ON (t_Load.Storage_Loc_Nbr = t_Item_Storage_Location.Storage_Loc_Nbr) AND (t_Load.MMM_Id_Nbr = t_Item_Storage_Location.MMM_Id_Nbr) where ((((t_Item_Storage_Location.MMM_Id_Nbr) Between '702004%' And '702011%') AND ((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%A') AND ((t_Storage_Location.Storage_Loc_Type_Code)='CD') AND ((t_Load.Active_Status_Ind)='A') AND ((t_Load.QC_Status_Code) Like 'R%') AND ((t_Load.MMM_Facility_Code)='MC')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%B')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%C')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%D')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%E')) ) GROUP BY t_Item_Storage_Location.MMM_Id_Nbr, t_Item_Storage_Location.Storage_Loc_Nbr, t_Storage_Location.Storage_Loc_Type_Code, t_Load.MMM_Facility_Code, t_load.MMM_Id_Nbr HAVING Count(t_Load.Load_Id)<4 The second one, is based on the t_load.MMM_Id_Nbr of the first one. Basically I want a count of all the loads with that mmm_id_nbr. SELECT count(Load_ID) as LoadCount, MMM_Id_Nbr, storage_Loc_Nbr FROM t_load WHERE QC_Status_Code like 'R%' and mmm_Facility_Code ='MC' and Active_Status_Ind='A' GROUP by MMM_Id_Nbr, storage_loc_Nbr

    Read the article

  • SQL Not Exists in this Query - is it possible

    - by jason barry
    This is my script - it simply looks for the image file associated to a person record. Now the error will display if there is NO .jpg evident when the query runs. Msg 4860, Level 16, State 1, Line 1 Cannot bulk load. The file "C:\Dev\ClientServices\Defence\RAN\Shore\Config\Photos\002054.2009469432270600.001.jpg" does not exist. Is there a way to write this query to 'IF not exists then set id_number = '002054.2009469432270427.001' - so it wil always display this photo for any records without a picture. ALTER procedure [dbo].[as_ngn_sp_REP_PH108_photo] (@PMKEYS nvarchar(50)) AS ---exec [as_ngn_sp_REP_PH108_photo] '8550733' SET NOCOUNT ON DECLARE @PATH AS NVARCHAR(255) DECLARE @ID_NUMBER NVARCHAR(27) DECLARE @SQL AS NVARCHAR(MAX) EXEC DB_GET_DB_SETTING'STAFF PICTURE FILE LOCATION', 0, @PATH OUTPUT IF RIGHT(@PATH,1) <> '\' SET @PATH = @PATH + '\' SELECT @ID_NUMBER = ID_NUMBER FROM aView_person WHERE EXTRA_CODE_1 = @PMKEYS SET @PATH = @PATH + @ID_NUMBER + '.jpg' SET @SQL = 'SELECT ''Picture1'' [Picture], BulkColumn FROM OPENROWSET(Bulk ''' + REPLACE(@PATH,'''','''''') + ''', SINGLE_BLOB) AS RAN' EXEC SP_EXECUTESQL @SQL

    Read the article

  • Is this query safe in SQL Server?

    - by xaw
    I have this SQL update query: UPDATE table1 SET table1.field1 = 1 WHERE table1.id NOT IN (SELECT table2.table1id FROM table2); Other portions of the application can add records to table2 which use the field table1id to reference table1. The goal here is to remove records from table1 which aren't referenced by table2. Does SQL Server automatically lock table2 with this kind of query so that a new record can't be added to table2 while executing this query? I've also considered: UPDATE table1 SET field1 = 1 WHERE 0 = (SELECT COUNT(*) FROM table2 WHERE table1.id = table2.table1id); Which seems possibly safer, but much slower (because a SELECT would be called on each row of table1 instead of just one select for the NOT IN)

    Read the article

  • Getting age in years in a SQL query

    - by Earlz
    Hello I've been tasked with doing a few queries on a large SQL Server 2000 database. The query I'm having trouble with is "find the number of people between ages 20 and 40" How would I do this? My previous query to get a count of everyone looks like this: select count(rid) from people where ... (with the ... being irrelevant conditions). I've googled some but the only thing I've found for calculating age is so large that I don't see how to embed it into a query, or it is a stored procedure which I do not have the permissions to create. Can someone help me with this?

    Read the article

  • What is wrong with this simple update query?

    - by Kyle Noland
    I get no error message, but the row is not updated. The rows integer is set 1 following the query, indicating that 1 row was affected. String query = "UPDATE contacts SET contact_name = '" + ContactName.Text.Trim() + "', " + "contact_phone = '" + Phone.Text.Trim() + "', " + "contact_fax = '" + Fax.Text.Trim() + "', " + "contact_direct = '" + Direct.Text.Trim() + "', " + "company_id = '" + Company.SelectedValue + "', " + "contact_address1 = '" + Address1.Text.Trim() + "', " + "contact_address2 = '" + Address2.Text.Trim() + "', " + "contact_city = '" + City.Text.Trim() + "', " + "contact_state = '" + State.SelectedValue + "', " + "contact_zip = '" + Zip.Text.Trim() + "' " + "WHERE contact_id = '" + contact_id + "'"; String cs = Lib.GetConnectionString(null); SqlConnection conn = new SqlConnection(cs); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = query; cmd.Connection.Open(); int rows = cmd.ExecuteNonQuery();

    Read the article

  • Dynamically set the result of a TSQL query using CASE WHEN

    - by Name.IsNullOrEmpty
    SELECT MyTable.Name,(SELECT CASE WHEN ISNULL(SUM(TotalDays), 0) <= 0 THEN 0 ELSE SUM(TotalDays) END AS Total FROM Application AS Applications WHERE (ID = MyTable.id)) - MIN(Assignments) AS Excesses FROM MyTable The above TSQL statement is a subquery in a main query. When i run it, if TotalDays is NULL or <=0, then Total is set to 0 (zero). What i would like to do here is to set the result of the whole query(Excesses) to 0. I want (Excesses) which is the result of Total - Min(Assignments) to be set to 0 if its NULL or <=0. I want the CASE WHEN to apply to the whole query but am struggling to get it right.

    Read the article

  • Cannot connect to a 2008 sql server named instance hosted in a azure virtual machine

    - by emardini
    When I try to connect to a named instance in a SQL SERVER hosted in a azure VM I get this message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1) The problem is the sql browser is not working properly, when I start the sql browser service it closes after a few seconds and the event log says "There are no instances of SQL Server or SQL Server Analysis Services." But I do have a named instance, I can connect locally to this instance. I've re-installed sql browser and the instance but ii does not work. The host is a azure virtual machine windows server 2008 datacenter. Please help. Thank you

    Read the article

  • Difference between SQL 2005 and SQL 2008 for inserting multiple rows with XML

    - by Sam Dahan
    I am using the following SQL code for inserting multiple rows of data in a table. The data is passed to the stored procedure using an XML variable : INSERT INTO MyTable SELECT SampleTime = T.Item.value('SampleTime[1]', 'datetime'), Volume1 = T.Item.value('Volume1[1]', 'float'), Volume2 = T.Item.value('Volume2[1]', 'float') FROM @xml.nodes('//Root/MyRecord') T(item) I have a whole bunch of unit tests to verify that I am inserting the right information, the right number of records, etc.. when I call the stored procedure. All fine and dandy - that is, until we began to monkey around with the compatibility level of the database. The code above worked beautifully as long as we kept the compatibility level of the DB at 90 (SQL 2005). When we set the compatibility level at 100 (SQL 2008), the unit tests failed, because the stored procedure using the code above times out. The unit tests are dropping the database, re-creating it from scripts, and running the tests on the brand new DB, so it's not - I think - a question of the 'old compatibility level' sticking around. Using the SQL Management studio, I made up a quick test SQL script. Using the same XML chunk, I alter the DB compat level , truncate the table, then use the code above to insert 650 rows. When the level is 90 (SQL 2005), it runs in milliseconds. When the level is 100 (SQL 2008) it sometimes takes over a minute, sometimes runs in milliseconds. I'd appreciate any insight anyone might have into that. EDIT The script takes over a minute to run with my actual data, which has more rows than I show here, is a real table, and has an index. With the following example code, the difference goes between milliseconds and around 5 seconds. --use [master] --ALTER DATABASE MyDB SET compatibility_level =100 use [MyDB] declare @xml xml set @xml = '<?xml version="1.0"?> <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Record> <SampleTime>2009-01-24T00:00:00</SampleTime> <Volume1>0</Volume1> <Volume2>0</Volume2> </Record> ..... 653 records, sample time spaced out 4 hours ........ </Root>' DECLARE @myTable TABLE( ID int IDENTITY(1,1) NOT NULL, [SampleTime] [datetime] NOT NULL, [Volume1] [float] NULL, [Volume2] [float] NULL) INSERT INTO @myTable select T.Item.value('SampleTime[1]', 'datetime') as SampleTime, Volume1 = T.Item.value('Volume1[1]', 'float'), Volume2 = T.Item.value('Volume2[1]', 'float') FROM @xml.nodes('//Root/Record') T(item) I uncomment the 2 lines at the top, select them and run just that (the ALTER DATABASE statement), then comment the 2 lines, deselect any text and run the whole thing. When I change from 90 to 100, it runs all the time in 5 seconds (I change the level once, but I run the series several times to see if I have consistent results). When I change from 100 to 90, it runs in milliseconds all the time. Just so you can play with it too. I am using SQL Server 2008 R2 standard edition.

    Read the article

  • Function Folding in #PowerQuery

    - by Darren Gosbell
    Originally posted on: http://geekswithblogs.net/darrengosbell/archive/2014/05/16/function-folding-in-powerquery.aspxLooking at a typical Power Query query you will noticed that it's made up of a number of small steps. As an example take a look at the query I did in my previous post about joining a fact table to a slowly changing dimension. It was roughly built up of the following steps: Get all records from the fact table Get all records from the dimension table do an outer join between these two tables on the business key (resulting in an increase in the row count as there are multiple records in the dimension table for each business key) Filter out the excess rows introduced in step 3 remove extra columns that are not required in the final result set. If Power Query was to execute a query like this literally, following the same steps in the same order it would not be overly efficient. Particularly if your two source tables were quite large. However Power Query has a feature called function folding where it can take a number of these small steps and push them down to the data source. The degree of function folding that can be performed depends on the data source, As you might expect, relational data sources like SQL Server, Oracle and Teradata support folding, but so do some of the other sources like OData, Exchange and Active Directory. To explore how this works I took the data from my previous post and loaded it into a SQL database. Then I converted my Power Query expression to source it's data from that database. Below is the resulting Power Query which I edited by hand so that the whole thing can be shown in a single expression: let     SqlSource = Sql.Database("localhost", "PowerQueryTest"),     BU = SqlSource{[Schema="dbo",Item="BU"]}[Data],     Fact = SqlSource{[Schema="dbo",Item="fact"]}[Data],     Source = Table.NestedJoin(Fact,{"BU_Code"},BU,{"BU_Code"},"NewColumn"),     LeftJoin = Table.ExpandTableColumn(Source, "NewColumn"                                   , {"BU_Key", "StartDate", "EndDate"}                                   , {"BU_Key", "StartDate", "EndDate"}),     BetweenFilter = Table.SelectRows(LeftJoin, each (([Date] >= [StartDate]) and ([Date] <= [EndDate])) ),     RemovedColumns = Table.RemoveColumns(BetweenFilter,{"StartDate", "EndDate"}) in     RemovedColumns If the above query was run step by step in a literal fashion you would expect it to run two queries against the SQL database doing "SELECT * …" from both tables. However a profiler trace shows just the following single SQL query: select [_].[BU_Code],     [_].[Date],     [_].[Amount],     [_].[BU_Key] from (     select [$Outer].[BU_Code],         [$Outer].[Date],         [$Outer].[Amount],         [$Inner].[BU_Key],         [$Inner].[StartDate],         [$Inner].[EndDate]     from [dbo].[fact] as [$Outer]     left outer join     (         select [_].[BU_Key] as [BU_Key],             [_].[BU_Code] as [BU_Code2],             [_].[BU_Name] as [BU_Name],             [_].[StartDate] as [StartDate],             [_].[EndDate] as [EndDate]         from [dbo].[BU] as [_]     ) as [$Inner] on ([$Outer].[BU_Code] = [$Inner].[BU_Code2] or [$Outer].[BU_Code] is null and [$Inner].[BU_Code2] is null) ) as [_] where [_].[Date] >= [_].[StartDate] and [_].[Date] <= [_].[EndDate] The resulting query is a little strange, you can probably tell that it was generated programmatically. But if you look closely you'll notice that every single part of the Power Query formula has been pushed down to SQL Server. Power Query itself ends up just constructing the query and passing the results back to Excel, it does not do any of the data transformation steps itself. So now you can feel a bit more comfortable showing Power Query to your less technical Colleagues knowing that the tool will do it's best fold all the  small steps in Power Query down the most efficient query that it can against the source systems.

    Read the article

  • Optimize SQL databases by adding index columns

    - by Viktor Sehr
    This might be implementation specific so the question regards how SQL databases is generally implemented. Say I have a database looking like this; Product with columns [ProductName] [Price] [Misc] [Etc] Order with columns [OrderID] [ProductName] [Quantity] [Misc] [Etc] ProductName is primary key of Product, of some string type and unique. OrderID is primary key and of some integer type, and ProductName being a foreign key. Say I change the primary key of Product to a new column of integer type ie [ProductID] Would this reduce the database size and optimize lookups joining these two tables (and likewise operations), or are these optimizations performed automatically by (most/general/main) SQL database implementations?

    Read the article

  • SQL Join to only the maximum row puzzle

    - by Billy ONeal
    Given the following example data: Users +--------------------------------------------------+ | ID | First Name | Last Name | Network Identifier | +--------------------------------------------------+ | 1 | Billy | O'Neal | bro4 | +----+------------+-----------+--------------------+ | 2 | John | Skeet | jsk1 | +----+------------+-----------+--------------------+ Hardware +----+-------------------+---------------+ | ID | Hardware Name | Serial Number | +----+-------------------+---------------+ | 1 | Latitude E6500 | 5555555 | +----+-------------------+---------------+ | 2 | Latitude E6200 | 2222222 | +----+-------------------+---------------+ HardwareAssignments +---------+-------------+-------------+ | User ID | Hardware ID | Assigned On | +---------+-------------+-------------+ | 1 | 1 | April 1 | +---------+-------------+-------------+ | 1 | 2 | April 10 | +---------+-------------+-------------+ | 2 | 2 | April 1 | +---------+-------------+-------------+ | 2 | 1 | April 11 | +---------+-------------+-------------+ I'd like to write a SQL query which would give the following result: +--------------------+------------+-----------+----------------+---------------+-------------+ | Network Identifier | First Name | Last Name | Hardware Name | Serial Number | Assigned On | +--------------------+------------+-----------+----------------+---------------+-------------+ | bro4 | Billy | O'Neal | Latitude E6200 | 2222222 | April 10 | +--------------------+------------+-----------+----------------+---------------+-------------+ | jsk1 | John | Skeet | Latitude E6500 | 5555555 | April 11 | +--------------------+------------+-----------+----------------+---------------+-------------+ My trouble is that the maximum "Assigned On" date for each user needs to be selected for each individual user and used for the actual join ... Is there a clever way accomplish this in SQL?

    Read the article

  • Adjusting sql statement in a function based upon input

    - by Stefan
    Hey there, This is a bit urgent! I'm trying to make a simple filter search where-by you can choose from a series of 3 drop downs and then based upon this the results are then displayed, How would I go about adjusting the sql query for each and if you were to only choose to search from aone of the 3 rather than all 3 etc... example there could be the url with input such as: url.com?location=gb&color=3&hair=4 and still form the correct sql query for something like this: url.com?location=gb&hair=1 and not encounter problems with WHERE and AND etc etc and empty variables in the statement Would this not need to be a massive function to check using if to see how the data is set for all possibilities? Thanks, Stefan

    Read the article

  • Selecting data from SQL Server table according to Month

    - by MarceloRamires
    I have to come up with a way to get data from a SQL server table given it's month There's a smalldatetime type field called "date" in the "events" table and a field from it looks like this: 29/01/2003 17:00:00 It should be one among those that appear in the gridview when I select jan/03 in a given DropDownList control in ASP.NET. What would be the best way to do this? Assuming I only want to go as long as 10 years to the past, wouldn't making a dictionary be a good way? How do I change it so the top month is always the current, and each month another options appeaars in the dropdown ? It should be a common issue, so that shall not be a trick, but I want a good and clean way of doing this, and (since I'm new to asp.net) I myself would come up with something messy after a long time trying. So what I want is: -Select -Best way of populating DropDownList (with the current month always at the top) -Best way to bind the DropDownList user-friendly way of writing months to the select query-friendly way of writing datetimes Info: ASP.NET, (C# or VB.NET), SQL Server 2005

    Read the article

  • SQL count NULL cells

    - by Giuseppe
    Dear All, I have the following problem. I have a table in a db, with many columns. I can do different kind of select queries, to show, for example, for each record that satisfies a condition: all cells from columns with names ending in _t0 all cells from columns with names ending in _t1 ... To get the column lists to form the queries I use the information schema. Now, the problem: each query returns a record with a subset of the columns of the big table. This means that I can get a row of (all!) NULLs. How can I ask my query to reject such rows without having to type in explicitely the column names (i.e. by saying where col_1 is not null, col_2 is not null...)? Is it possible? Thanks in advance!!! Sep

    Read the article

  • Problem with a SQL statement

    - by benwad
    I'm trying to enter values into a database table using a form and a PHP function. The PHP seems to be fine as the SQL statement it creates looks okay, but the database always throws up an error. This is the SQL statement that my code has generated (with arbitrary values): INSERT INTO Iteminfo ('itemName', 'itemSeller', 'itemCategory', 'itemDescription', 'itemPrice', 'itemPostage', 'itemBegin', 'itemEnd', 'buynow', 'itemPicture') values ('gorillaz album', 'ben', 'music', 'new one ', '5.00', '1.00', '2010-03-15 14:59:51', '2010-03-16 14:59:51', '0', 'http://www.thefader.com/wp-content/uploads/2010/01/gorillaz-plastic-beach.jpg') This throws up an error both when I use the PHP function to evaluate the query and also when I use phpMyAdmin to enter the query manually. However, I can't see anything wrong with it. Can anyone shed some light on this? All of the fields are VARCHAR values, except for itemPrice and itemPostage (which are stored as DECIMAL(4,2)) and the itemBegin and itemEnd, which are stored as DATETIMEs.

    Read the article

  • SQl to list rows if not in another table

    - by SmartestVEGA
    I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees where GroupStartDate < '20100301' and StaffDiscountStartDate > '20100301' and datediff(day,groupstartdate,staffdiscountstartdate)>1 order by staffdiscountstartdate desc i have the following query which have 400 rows: ie the employees in tblemployees and in tblcards select a.employeeid,b.employeeid from tblEmployees a,tblCards b where GroupStartDate < '20100301' and StaffDiscountStartDate > '20100301' and datediff(day,groupstartdate,staffdiscountstartdate)>1 and a.employeeid=b.employeeid How to list the employees which is there in tblemployees and not in tblcards? ie is 1000-400 = 600 rows ???

    Read the article

< Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >