Forum Replies Created

Viewing 15 posts - 4,216 through 4,230 (of 7,597 total)

  • RE: How to write tsql for report

    Probably the easiest way is to use derived tables within a main query, like below, assuming that each derive table returns only a single row:

    SELECT q1.*, q2.*, q3.* --, ...

    FROM...

  • RE: The effect of nolock on the sort order of a view

    In theory, it's also possible that you could get any 1,000 rows that are already present in buffers and thus don't require physical I/O. Without an ORDER BY, any...

  • RE: Very generic question

    Some things to check, roughly in order:

    1) Verify that a valid and reasonable "max memory" value is set in SQL Server.

    2) Verify that IFI is turned on in Windows to...

  • RE: Flattening Nested Views

    I can't imagine any tool that would be able to do that, given that each view level could be arbitrarily complex.

  • RE: Better method for computed column?

    mike 57299 (7/25/2016)


    I use the index for other queries as well. Can I create a new filtered index? How do I make the function use the new index?...

  • RE: Better method for computed column?

    I agree overall with Alan's comments. If you're willing to convert existing code/queries, also look into an itvf to do the computation.

    However, for now, let's tune what you have....

  • RE: Reducing the hash match inner join cost

    Jeff Moden (7/21/2016)


    ScottPletcher (7/21/2016)


    Jeff Moden (7/20/2016)


    ScottPletcher (7/20/2016)


    If the "isactive" flag is significant, i.e. a significant number of rows are actually inactive, then cluster first on it. If not, get...

  • RE: Reducing the hash match inner join cost

    Jeff Moden (7/20/2016)


    ScottPletcher (7/20/2016)


    If the "isactive" flag is significant, i.e. a significant number of rows are actually inactive, then cluster first on it. If not, get rid of it....

  • RE: Reducing the hash match inner join cost

    If the "isactive" flag is significant, i.e. a significant number of rows are actually inactive, then cluster first on it. If not, get rid of it. At the...

  • RE: UNIQUE Constraint Help please

    You could use a standard unique constraint if you continually deleted searches 2 hours or more old from the table. For example, have a job that deletes rows every...

  • RE: Rounding datetime to midnight

    The "standard/best-practice" way to get yesterday's date is:

    DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) - 1, 0)

    Based on that, then make the necessary 6-hour adjustment on the starting time [the "+" in the...

  • RE: Allowing a user to run a Job

    While logged in as sysadmin, create a stored proc that includes "WITH EXECUTE AS OWNER". In that proc, have the command:

    EXEC msdb..sp_start_job @job_name = @job_name, ...

    Then GRANT the role(s)/user(s)...

  • RE: Not a DBA admin - How do i optimize/tune my queries, check on missing index?

    To do any proper type of index tuning, you must have access to at least:

    missing index stats, via sys.dm_db_missing* views;

    index usage stats, via sys.dm_db_index_usage_stats;

    index operational stats, via sys.dm_db_index_operational stats.

    With that,...

  • RE: Aggregating Correlated Sub-Queries

    I don't think the need the GROUP BY on the outer query, just a SUM() OVER(), so maybe this?:

    SELECT

    f.Country

    ,f.CompanyName

    ,f.InvoiceID

    ,f.SupplierCode

    ,f.InvoiceNumber

    ,f.[Scan Date]

    ,f.[Approval Date]

    ,f.[Days to Final Approval]

    ,f.[<7 Days]

    ,f.[>7 Days]

    ,SUM([>7 Days]) OVER(PARTITION BY f.Country...

  • RE: Restoring 100s of user databases..

    You really do need a stored proc, given how complex the restore process could be, with a full backup, maybe differential, maybe log file(s).

    I have a special user/utility db that...

Viewing 15 posts - 4,216 through 4,230 (of 7,597 total)