Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. SyntaxTerror

    Changing Date Style

    I'm trying to change a date from 2005-10-01 00:00:00.000 to Oct-05. I would need this to work for any month. How can I do this? I'm using SQL Server 2005. Thanks!
  2. SyntaxTerror

    Stripping dates from something in the WHERE only (not in select)

    We have a report where we allow the user to specify a date range and pull all of the purchase orders pulled between the specified dates. Well, there is a problem with the report. The code is like this: WHERE CreatedDate BETWEEN @begindate AND @enddate If the begin date is 2011-06-29 and the...
  3. SyntaxTerror

    Stuck on what kinds of joins to use... Info inside

    I am pulling from a few temp tables and am not sure how to join them so I get the right results. The goal is, in essence, to make the following calculation: InventoryCount1+PurchaseOrdersMadeBetweenCount1and2-InventoryCount2=InventoryUsage Tables: 1) Inventory Counts Temp Table containing...
  4. SyntaxTerror

    Filter Optimization - Filtering for only #s when datatype is CHAR(30)

    Hello again :) Thanks not in small part to the assistance of you fine people, I have my 6-pages of code working. Now I'm working on optimizing it. I've knocked the run time down from 11 seconds to 6, but I know of a couple other places I could speed it up. One is with filtering inventory...
  5. SyntaxTerror

    The multi-part identifier "[alias].[field]" could not be bound

    SQL Server 2005 is saying that Wk1Usage.Wk1Usage in the update statement for my temp table can't be bound, but I don't see any problems with my syntax. Help? :S The subquery in the update runs flawlessly. CREATE TABLE #temp_usage ( SiteID CHAR(10), InvtID CHAR(30), Wk1Usage FLOAT...
  6. SyntaxTerror

    Syntax to use IS NOT NULL with IN? ...perhaps another way?

    Maybe I'm thinking of this wrongly, but I have a situation where, if the values in 6 different columns are ALL null, I don't want to display that row. For example, column 1 is InventoryID, then columns 2-7 will be Week1Quantity, Week1Quantity, Week3Quantity, etc. If all 6 weeks of quantity...
  7. SyntaxTerror

    Referring to an aliased aggregate function in where?

    If, in my select, I have something like SUM(Quantity) as TotalQty ...Then how do I refer to that in the where clause? I want to say... WHERE TotalQty IS NOT NULL ...but it doesn't recognize the alias, so I try... WHERE sum(Quantity) IS NOT NULL ...but it won't take that either. Workarounds?
  8. SyntaxTerror

    Creating a temp table for a lot of data

    I'm writing a complicated script requiring a lot of logic, to the point that I can't make all of the calculations in a single statement. I got to the point where I had something like 5 nested subqueries, SQL wasn't liking it, and my coworker said I was overcomplicating it (the logic of the...
  9. SyntaxTerror

    Using SubQueries with Between

    Hello :) What would be the best way to implement this where statement pseudocode with proper syntax? Basically, I'm trying to pull dates out of a temp table I've created using subqueries WHERE CreatedDateTime BETWEEN (SELECT StartDate FROM #temp) AND (SELECT EndDate FROM #temp) The...
  10. SyntaxTerror

    Max date in case statement pulling 2007 instead of 2011

    ntaxTerror (TechnicalUser) Jan 6, 2011 I have a CASE statement where I'm using MAX in my WHEN and it's failing the conditions of the WHEN because the date doesn't fall within the specified range, when it should. Looking at the date output, it pulls a date of 2007-01-09 when it should pull...
  11. SyntaxTerror

    DATEADD not working as expected

    I'm writing a report that will go back from the current date and break it up into weekly periods, so I wanted to use DATEADD to achieve this by doing something like... DECLARE @CurrDate as TimeStamp SELECT CASE WHEN CreatedDate BETWEEN DATEADD(D, -7, @CurrDate) and DATEADD (D, 1, @CurrDate)...

Part and Inventory Search

Back
Top