Forum Replies Created

Viewing 15 posts - 226 through 240 (of 1,183 total)

  • RE: Howto... sqlquery returning field1 where field2 is multiple criteria...

    There are a few ways to skin this cat, but here are two ....

    DECLARE @a TABLE

    (CriteriaKoppelID INT, fkObjectID INT, fkCriteriaID INT)

    INSERT @a SELECT 1,1,17

    INSERT @a SELECT 2,1,18

    INSERT @a SELECT...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Two databases - same instance - query both

    Alias' and Synonyms are similar, but not the same.

    An alias only lives as long as your query. Synonyms live as long as the database lives OR they are dropped.

    There are...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: No.of weekdays in each month

    GSquared (11/21/2011)


    Here's a solution that doesn't use a Calendar table:

    CREATE PROC dbo.DeleteMe

    (@WeekDay INT,

    @FromDate DATE,

    @ToDate DATE)

    AS

    ...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: No.of weekdays in each month

    Jason Selburg (11/21/2011)


    Provided Sunday is your DATEFIRST

    SELECT

    sum(CASE WHEN datepart(dw,getdate()) BETWEEN 2 AND 6 THEN 1 ELSE 0 END)

    WHERE TheDate between @fromdate AND @ToDate

    OOPS, change the...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: No.of weekdays in each month

    Provided Sunday is your DATEFIRST

    SELECT

    sum(CASE WHEN datepart(dw,TheDate) BETWEEN 2 AND 6 THEN 1 ELSE 0 END)

    WHERE TheDate between @fromdate AND @ToDate

    EDIT: Typo corrected.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: No.of weekdays in each month

    You are much better off creating a dates table. This is just one of it's many uses.

    http://www.sqlservercentral.com/scripts/Date/68389/

    While you're at it, you might as well create a Tally table too.

    http://www.sqlservercentral.com/articles/T-SQL/62867/

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Using the INTERSECT command in a function

    Gazareth (11/18/2011)


    Ha sorry I've just done your original function again. Home time I think!

    Maybe this:

    RETURN ( CASE WHEN

    (SELECT COUNT(Credit_ID)

    FROM

    (

    SELECT Credit_ID

    FROM DIP.dbo.ProgramCredit

    WHERE Program_ID = @ProgramID1

    INTERSECT

    SELECT Credit_ID

    FROM DIP.dbo.ProgramCredit

    WHERE Program_ID = @ProgramID2

    ) z

    )...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Using the INTERSECT command in a function

    CREATE FUNCTION dbo.CreditOverlap

    (@ProgramID1 INT

    ,@ProgramID2 INT)

    RETURNS BIT

    AS

    BEGIN

    RETURN (SELECT CASE WHEN COUNT(*) > 1 THEN 1 ELSE 0 END

    ...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: What about contract to hire

    And don't forget the REAL benefit of contract to hire. You get to decide if you want to stay there too, without taking a hit on your resume for such...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: question on best practices

    whole (11/17/2011)


    How often will you be doing this comparison? Daily, Hourly, Every millisecond, as part of another process, etc...?

    may be 7-8 times a day

    How many records are you talking about...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: question on best practices

    as with anything in SQL "it depends."

    How often will you be doing this comparison? Daily, Hourly, Every millisecond, as part of another process, etc...?

    How many records are you talking about...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Pivot table query - making it dynamic

    terryshamir (11/17/2011)


    Thanks Jason. I could do this becuase for every svcname there is a contious SVCID which is an Identity field. So I could add say 10 onto the last...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Pivot table query - making it dynamic

    This isn't completely dynamic, but close.

    Instead of using SvcName, use a key/identity (1,2,3,4,5 ....) write the pivot to reference the key and have a set # that is more than...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Database Collation: Case Sensitive or Insensitive

    I completely agree it's annoying as hell. What I'm looking for are arguments for and against. 😀

    I am 100% against CS, FYI.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Help with Math in SELECT stmt

    Although adding a simple "." does the same. 🙂

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg

Viewing 15 posts - 226 through 240 (of 1,183 total)