Forum Replies Created

Viewing 15 posts - 16 through 30 (of 31 total)

  • RE: Best Way to Calculate Age

    The third query is wrong:

    DATEDIFF(yy, DateOfBirth, GETDATE()) - CASE WHEN DATEPART(m, DateOfBirth) >= DATEPART(m, GETDATE()) AND DATEPART(d, DateOfBirth) >= DATEPART(d, GETDATE()) THEN 0 ELSE 1 END

    It instead should be:

    DATEDIFF(yy,...

  • RE: enhancing sql command

    All (especially Ralph):

    There are three JOIN clauses and only two ON clauses. Each JOIN clause should have a corresponding ON clause.

    Again, good luck all!!!!

  • RE: enhancing sql command

    1) Assuming RecordedCalls is the table with 10 million records, and given this table has a DateTime column (CallDate) that you're filtering on in your WHERE clause, why don't...

  • RE: Migrating SQL Server 2000 DTS Packages Across Environments

    How do I download import.zip and extract.zip? I need to see the .bat files, not just the VB6 code files.

    Thanks,

    --Jeff

  • RE: Question of the Day for 28 Jul 2006

    Instead of using a subquery, an easier solution is:

    SELECT E.LastName + ', ' + E.FirstName AS [Employee Name], COUNT(O.EmployeeID) [# of Orders]
    FROM dbo.Employees E  LEFT JOIN dbo.Orders O ON (E.EmployeeID...
  • RE: Can you order by on datename?

    govinn:

    Good catch.  I didn't unit test the solution first.  Without writing a subquery, you need to include the item you want to sort by in the SELECT statement also.  Therefore, the...

  • RE: Can you order by on datename?

    Actually the correct solution to Alex's original question is:

    SELECT distinct datename(mm, events.date) as Months

    FROM Events

    where datepart(month, events.date) between 5 and 6

    order by charindex(left(datename(mm,events.date),3),'JanFebMarAprMayJunJulAugSepOctNovDec')

  • RE: Can you order by on datename?

    Joe's answer is close to correct, but it has a small error in it.  He should be using the DATENAME function instead of DATEPART.  Also, the DATENAME function returns the...

  • RE: AND/OR problems...

    Remi:

    I agree with you that there are many ways to "skin a cat".  Here is another, related solution.

    User Defined Function for Support

    CREATE dbo.fnCountDelimiters(@sInput varchar(8000), @sDelimiter varchar(1))

    RETURNS int

    AS

    BEGIN

    DECLARE @iCount int,...

  • RE: AND/OR problems...

    Remi:

    I agree that it would be nice if we could construct a static query and just pass in a delimited string to represent the list of keywords.

    Unfortuncately, I still don't...

  • RE: AND/OR problems...

    OOPS!!!!!!!!!!!!

    My mind went blank!  Ignore the above "simple solution".

    Unfortunately, the only way to solve this using my technique with derived tables is to use VB.NET or C# to construct a...

  • RE: AND/OR problems...

    Remi:

    Thanks for the reply.  I just thought of a much simpler solution that involves the use of a trivial user defined function (UDF).

    Here is the UDF:

    CREATE FUNCTION dbo.fnCountKeywords(@KeywordID int)

    RETURNS int

    AS

    BEGIN

    DECLARE @Count...

  • RE: AND/OR problems...

    This is an interesting problem.  I think I have a better solution.  Your solution only finds proposals that have KeywordID of 12 and 23 exactly, and no other keywords are...

  • RE: Key Fields

    Ling Ming:

    What error message are you getting from the debugger on the line:

    For Each idx in tbl.Indexes

    Also, can you see other properties for tbl in the Immediate window (e.g. tbl.Name,...

  • RE: Key Fields

    1)  For the VB code, you need to reference ADODB (e.g. Microsoft ActiveX Data Objects 2.7 Library) and ADOX (e.g. Microsoft ADO Ext 2.7 for DDL and Security).  Here is...

Viewing 15 posts - 16 through 30 (of 31 total)