Forum Replies Created

Viewing 15 posts - 13,696 through 13,710 (of 14,953 total)

  • RE: Many to Many join with date ranges

    All five of those are covered by the conditions in Mark's query. I've used that method before, and it works.

  • RE: Execute a Stored Proc as a background process

    Another thing you can do is create a startup proc, and use the WaitFor command and a While loop to make it execute something over and over again.

    While 1...

  • RE: Why VIEW changes my query?

    I've actually seen the graphical query designer break a working query by doing this kind of auto"fixing".

    The query included a self-join on a table, with 7 iterations of the self-join.

    When...

  • RE: SQL Query Tuning

    Matt Miller (5/13/2008)


    GSquared (5/12/2008)


    declare @FirstDate datetime, @LastDate datetime

    select @FirstDate = CONVERT(VARCHAR(10),DATEADD(m,-7,GETDATE()),101),

    @LastDate = CONVERT(VARCHAR(10), GETDATE(), 101)

    SELECT

    t1.Date_Taken, t1.Time,

    t1.Main_ID, t1.WATER_ULEVEL

    FROM dbo.tblSEL t1 INNER JOIN dbo.tblLocation t2

    ON t1.Main_ID=t2.Main_ID

    WHERE t2.Location='PRK'

    AND t1.Date_Taken>=@FirstDate AND

    t1.Date_Taken<=@LastDate

    ORDER BY t1.Date_Taken,...

  • RE: Help to simplify the query

    You're welcome. (I still recommend taking a look at index use for this, if you haven't already.)

  • RE: Mirroring - High Availability

    Best set it up on the mirror. If the whole idea is to handle problems when the principle goes down, you don't want the principle going down to take...

  • RE: String comparison with trailing spaces

    Matt Miller (5/13/2008)


    GSquared (5/13/2008)


    I just checked my databases and servers, and ANSI padding is False on all of them, but per BOL:

    Important:

    In a future version of SQL Server...

  • RE: Problems Starting & Stopping Services Remotely using xp_cmdshell

    xp_cmdshell on some servers is set up to run under a different account than the SQL service. Have you checked that?

  • RE: Mirroring - High Availability

    Yes. A witness server is recommended, but not required.

  • RE: String comparison with trailing spaces

    I just checked my databases and servers, and ANSI padding is False on all of them, but per BOL:

    Important:

    In a future version of SQL Server ANSI_PADDING will always...

  • RE: String comparison with trailing spaces

    Matt:

    Your test doesn't quite do it:

    set ansi_padding on

    go

    create table #T(k varchar(10) primary key clustered)

    insert #T

    select 'a' union all

    select 'a ' union all

    select 'a ' union all

    select 'a ...

  • RE: String comparison with trailing spaces

    Per BOL, the column behavior is set when the column is created. The setting in place when you insert/select/update doesn't affect it. That might be affecting your tests,...

  • RE: Why VIEW changes my query?

    The graphical query designer in QA/Enterprise Manager has its own layout. A really, really annoying one that nobody has ever yet managed to find readable. Code you put...

  • RE: Many to Many join with date ranges

    Mark's solution is the one I would use. Should do exactly what you need.

  • RE: Query to match some fields out of many - HELP !

    If you have a primary key on the table, I'd recommend creating a temporary table and doing something like this:

    create table #T (

    ID int)

    insert into #t (ID)

    select ID

    from MyTable

    where Col1...

Viewing 15 posts - 13,696 through 13,710 (of 14,953 total)