Search Results

Search found 4908 results on 197 pages for 'ssas 2005'.

Page 96/197 | < Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >

  • SQL Full Outer Join

    - by Torment March
    I have a table named 'Logs' with the following values : CheckDate CheckType CheckTime ------------------------------------------- 2011-11-25 IN 14:40:00 2011-11-25 OUT 14:45:00 2011-11-25 IN 14:50:00 2011-11-25 OUT 14:55:00 2011-11-25 IN 15:00:00 2011-11-25 OUT 15:05:00 2011-11-25 IN 15:15:00 2011-11-25 OUT 15:20:00 2011-11-25 IN 15:25:00 2011-11-25 OUT 15:30:00 2011-11-25 OUT 15:40:00 2011-11-25 IN 15:45:00 I want to use the previous table to produce a result of: CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 14:40:00 14:45:00 2011-11-25 14:50:00 14:55:00 2011-11-25 15:00:00 15:05:00 2011-11-25 15:15:00 15:20:00 2011-11-25 15:25:00 15:30:00 2011-11-25 NULL 15:40:00 2011-11-25 15:45:00 NULL So far I have come up with this result set : CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 14:40:00 14:45:00 2011-11-25 14:50:00 14:55:00 2011-11-25 15:00:00 15:05:00 2011-11-25 15:15:00 15:20:00 2011-11-25 15:25:00 15:30:00 2011-11-25 15:45:00 NULL The problem is I cannot generate the log without CheckIns : CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 NULL 15:40:00 The sequence of CheckIn - CheckOut pairing and order is in increasing time value.

    Read the article

  • How many Stored Procedures created everyday ( problem in converting Datetime )?

    - by Space Cracker
    I make a query that return to me the count of Stored Procedure that created everyday as follow SELECT convert(varchar, crdate, 103) as Date,Count(*) as Counter FROM sysobjects WHERE (xtype = 'p') AND (name NOT LIKE 'dt%') Group by convert(varchar, crdate, 103) and its already work but dates appear in string format that i can't order it such as below 01/03/2010 3 01/04/2008 4 01/05/2010 5 01/11/2008 1 01/12/2008 4 02/03/2008 1 02/03/2010 2 02/04/2008 4 02/05/2010 2 02/11/2008 2 02/11/2009 2 02/12/2008 4 03/01/2010 1 03/02/2010 2 03/03/2010 2 03/04/2008 2 03/04/2010 2 03/05/2008 1 03/05/2010 2 I want to make that in which date is in datetime format that i can make order by successfully, i tried convert(datetime, crdate, 103) but it show Full date any idea of how to do ?

    Read the article

  • Is this a bad indexing strategy for a table?

    - by llamaoo7
    The table in question is part of a database that a vendor's software uses on our network. The table contains metadata about files. The schema of the table is as follows Metadata ResultID (PK, int, not null) MappedFieldname (char(50), not null) Fieldname (PK, char(50), not null) Fieldvalue (text, null) There is a clustered index on ResultID and Fieldname. This table typically contains millions of rows (in one case, it contains 500 million). The table is populated by 24 workers running 4 threads each when data is being "processed". This results in many non-sequential inserts. Later after processing, more data is inserted into this table by some of our in-house software. The fragmentation for a given table is at least 50%. In the case of the largest table, it is at 90%. We do not have a DBA. I am aware we desperately need a DB maintenance strategy. As far as my background, I'm a college student working part time at this company. My question is this, is a clustered index the best way to go about this? Should another index be considered? Are there any good references for this type and similar ad-hoc DBA tasks?

    Read the article

  • Sorting results by a char(1) column

    - by Brandon
    I have a stored procedure which basically does something like select top 1 expiryDate, flag, (bunch of other columns) from someTable (bunch of joins) order by expiryDate desc So this will grab the record that expires last. This works for most cases, except some records have a flag that are just a char(1). Most of the time it's just Y or N. So it'll return something like 2010-12-31 N 2010-10-05 Y 2010-08-05 N 2010-03-01 F 2010-01-31 N This works, most of the time, but is there any way to order it by the Flag column as well? So I'd want to group the results by Y, then N, and F and any other flags can go last in any order. I thought this would just be an order by, but since the flags are not weighted by the alphabetic value, I'm a little stumped. (Note: These are not my tables, I don't know if using the characters like this was a good idea or not, but it's not something I can change).

    Read the article

  • selecting number of rows from resultset

    - by sap
    Suppose a query "select * from employee" returns 80 rows. I need to display middle rows that is from 20th row to 50th row. I know, like to display first 20 rows we have option like "select top 20 * from employee" but if we need middle rows how to get it in MS SQL specifically. I m new to this SQL queries...Can anybody answer to this question.

    Read the article

  • Sql query number of occurance

    - by phenevo
    Hi, I wanna to have query: Select cars.* from cars where cars.code in ( select carCode from articles where numberofrecords with this car (it is not a column) >1 and Accepted=1 order by date ) How to write it?

    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

  • SQL Server PIVOT on key-value table

    - by Zenox
    I have a table that has attributes based on a key-value. Example: CREATE TABLE ObjectAttributes ( int objectId, key nvarchar(64), value nvarchar(512) ) When I select from this I get: objectId key value ---------------------------- 1 Key 1 Value 1 1 Key 2 Value 2 I was wondering if I could use the PIVOT syntax to turn this into: objectId Key 1 Key 2 --------------------------- 1 Value 1 Value 2 I know all of my tables will have the same keys. (Unfortunately I cannot easily change the table structure. This is what is leading me to attempt using PIVOTS). The big issue here though is that pivots require an aggression function to be used. Is there a way to avert this? Am I completely wrong attempting this? Or is there a better solution?

    Read the article

  • VS2005: two projects doing identical tasks but with different result

    - by Craig Johnston
    In VS2005 I have multi-project solution. Two of the projects use an external set of DLLs to create a report, using report definition data taken from an SQL Server. One of the projects creates the report just fine, but the other project results in an Exception. I have checked that the projects are referencing the same versions of the all the DLLs and they appear to be identical. What could the cause of this problem?

    Read the article

  • Querying for a unique value based on the aggregate of another value while grouping on a third value

    - by Justin Swartsel
    So I know this problem isn't a new one, but I'm trying to wrap my head around it and understand the best way to deal with scenarios like this. Say I have a hypothetical table 'X' that looks like this: GroupID ID (identity) SomeDateTime -------------------------------------------- 1 1000 1/1/01 1 1001 2/2/02 1 1002 3/3/03 2 1003 4/4/04 2 1004 5/5/05 I want to query it so the result set looks like this: ---------------------------------------- 1 1002 3/3/03 2 1004 5/5/05 Basically what I want is the MAX SomeDateTime value grouped by my GroupID column. The kicker is that I DON'T want to group by the ID column, I just want to know the 'ID' that corresponds to the MAX SomeDateTime. I know one pseudo-solution would be: ;WITH X1 as ( SELECT MAX(SomeDateTime) as SomeDateTime, GroupID FROM X GROUP BY GroupID ) SELECT X1.SomeDateTime, X1.GroupID, X2.ID FROM X1 INNER JOIN X as X2 ON X.DateTime = X2.DateTime But this doesn't solve the fact that a DateTime might not be unique. And it seems sloppy to join on a DateTime like that. Another pseudo-solution could be: SELECT X.GroupID, MAX(X.ID) as ID, MAX(X.SomeDateTime) as SomeDateTime FROM X GROUP BY X.GroupID But there are no guarantees that ID will actually match the row that SomeDateTime comes from. A third less useful option might be: SELECT TOP 1 X.GroupID, X.ID, X.SomeDateTime FROM X WHERE X.GroupID = 1 ORDER BY X.SomeDateTime DESC But obviously that only works with a single, known, GroupID. I want to be able to join this result set on GroupID and/or ID. Does anyone know of any clever solutions? Any good uses of windowing functions? Thanks!

    Read the article

  • need help understanding a function.

    - by Adam McC
    i had previously asked for help writing/improving a function that i need to calculate a premium based on differing values for each month. the premium is split in to 12 months and earned on a percentage for each month. so if the policy start in march and we are in jan we will have earned 10 months worth. so i need to add up the monthly earning to give us the total earned. wach company wil have differeing earnings values for each month. my original code is Here. its ghastly and slow hence the request for help. and i was presented with the following code. the code works but returns stupendously large figures. begin set @begin=datepart(month,@outdate) set @end=datepart(month,@experiencedate) ;with a as ( select *, case calmonth when 'january' then 1 when 'february' then 2 when 'march' then 3 when 'april' then 4 when 'may' then 5 when 'june' then 6 when 'july' then 7 when 'august' then 8 when 'september' then 9 when 'october' then 10 when 'november' then 11 when 'december' then 12 end as Mnth from tblearningpatterns where clientname=@client and earningpattern=@pattern ) , b as ( select earningvalue, Mnth, earningvalue as Ttl from a where Mnth=@begin union all select a.earningvalue, a.Mnth, cast(b.Ttl*a.earningvalue as decimal(15,3)) as Ttl from a inner join b on a.Mnth=b.Mnth+1 where a.Mnth<=@end ) select @earningvalue= Ttl from b inner join ( select max(Mnth) as Mnth from b ) c on b.Mnth=c.Mnth option(maxrecursion 12) SET @earnedpremium = @earningvalue*@premium end can someone please help me out?

    Read the article

  • SP: Random Records, Fave Record, Plus Known Record, NO repetition.

    - by Munklefish
    Hi, Thanks to help from a lot of you guys ive been given the following code which works great. However ive realised ive missed an important bit of info out of the question and so have reposted here (with updated code) to clarify. The following code gets 5 random records from a table plus a further single record based on the users favourite as identified in a second table: CREATE PROCEDURE web.getRandomCharities ( @tmp_ID bigint --members ID ) AS BEGIN WITH q AS ( SELECT TOP 5 * FROM TBL_CHARITIES WHERE cha_Active = 'TRUE' AND cha_Key != '1' ORDER BY NEWID() ) SELECT * FROM q UNION ALL SELECT TOP 1 * FROM ( SELECT * FROM TBL_CHARITIES WHERE TBL_CHARITIES.cha_Key IN ( SELECT members_Favourite FROM TBL_MEMBERS WHERE members_Id = @tmp_ID ) EXCEPT SELECT * FROM q ) tc END However, i realised i also need to include the record where "cha_Key == '1'" if it isnt the same as the record returned in the second SELECT statement in the code shown above. HOpe that makes sense? THANKS!!!

    Read the article

  • How to create festival calendar in ASP.net

    - by Atul
    I want to make a festival calendar using asp.net from that I used two ajax calendar and one textbox it is a festival textbox where we enter festival which FromDate and ToDate respectively. I want to do this as following point If I enter in textbox Christmas and Choose Fromdate=25/12/2011 and ToDate=31/12/2011 then it will be valid If I choose fromDate=25/12/2011 and ToDate=24/12/2011 then it will invalid If I choose Fromdate=25/12/2011 and Todate=28/12/2011 then also it is invalid because it coming in between 25/12/2011 and 31/12/2011 If I Choose fromdate=1/1/2011 and ToDate=1/1/2011 then it is valid If I choose fromdate=21/12/2011 and 25/12/2011 then it is invalid because of already Christmas done in 1/1/2011 And all date should show in gridview like 25-dec-2011 format Here is my code: DateTime dt1 = Convert.ToDateTime(txt_fromdate.Text); DateTime dt2 = Convert.ToDateTime(txt_todate.Text); if (dt1 > dt2) { con.Open(); com = new SqlCommand("BTNN_MovieDB_Festival_Details_Insert", con); com.Parameters.Add("@fromdate", SqlDbType.VarChar).Value = dateformat_mmdd(txt_fromdate.Text.ToString().Trim()); com.Parameters.Add("@todate", SqlDbType.VarChar).Value = dateformat_mmdd(txt_todate.Text.ToString().Trim()); com.Parameters.Add("@return", SqlDbType.VarChar).Direction = ParameterDirection.ReturnValue; com.ExecuteNonQuery(); con.Close(); showdata(); } else if (dt1 < dt2) { lblerror.Text = "ToDate should be greater than FromDate"; }

    Read the article

  • SQL query to select records from three Tables seperatly

    - by Azhar
    SQL query which select the record from three tables and there is no relation between these tables. Actually I want to make it a VIEW. suppose there are three tales Table1, Table2, Table3 I want to show records of Table1 first with some filter criteria and then the records from Table2 and in last from Table3 as when we execute the view it show like the records like a Table. There can be any number of rows but the records must be in this sequence.

    Read the article

  • How to check if the sum of some records equals the difference between two other records in t-sql?

    - by Dan Appleyard
    I have a view that contains bank account activity. ACCOUNT BALANCE_ROW AMOUNT SORT_ORDER 111 1 0.00 1 111 0 10.00 2 111 0 -2.50 3 111 1 7.50 4 222 1 100.00 5 222 0 25.00 6 222 1 125.00 7 ACCOUNT = account number BALANCE_ROW = either starting or ending balance would be 1, otherwise 0 AMOUNT = the amount SORT_ORDER = simple order to return the records in the order of start balance, activity, and end balance I need to figure out a way to see if the sum of the non balance_row rows equal the difference between the ending balance and the starting balance. The result for each account (1 for yes, 0 for no) would be simply added to the resulting result set. Example: Account 111 had a starting balance of 0.00. There were two account activity records of 10.00 and -2.5. That resulted in the ending balance of 7.50. I've been playing around with temp tables, but I was not sure if there is a more efficient way of accomplishing this. Thanks for any input you may have!

    Read the article

  • VSS causing crash in VS 2008

    - by David
    We use Visual Studio 2008, with visual source safe v8. Lately, I seem to be getting a lot more crashes than usual, mainly when viewing history (comparing, etc.). I have taken a screencapture of the series of dialog boxes that will always appear, leading up to the crash: http://img529.imageshack.us/img529/1360/msvscrash.jpg Does anyone know what could be causing this? Thanks.

    Read the article

  • how to fetch data from XML and update database table.

    - by ppp
    I am passing serialized collection(XML) to stored procedure. My XML structure is- <ArrayofDepartmentEntity> <Department> <id>1004</id> <budget>2500.oo</budget> </Department> <Department> <id>1080</id> <budget>3500.oo</budget> </Department> <Department> <id>1029</id> <budget>4500.00</budget> </Department> </ArrayofDepartmentEntity> How can I UPDATE corresponding budget column where department IDs are in above XML?? can any body write down the sql syntax. my SP syntax- ALTER PROCEDURE [dbo].[usp_SaveDepartentBudget] ( @departmentBudgetXML ntext = NULL ) AS BEGIN DECLARE @ptrHandle int EXEC sp_xml_preparedocument @ptrHandle OUTPUT, @departmentBudgetXML ....Here I want to update Budget foreach departmentID in @departmentBudgetXML

    Read the article

< Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >