Forum Replies Created

Viewing 15 posts - 4,141 through 4,155 (of 8,761 total)

  • RE: Get tables size info from all databases from sql server

    Quick solution

    😎

    USE master;

    GO

    SET NOCOUNT ON;

    IF OBJECT_ID(N'tempdb.dbo.temp_result') IS NOT NULL DROP TABLE tempdb.dbo.temp_result;

    CREATE TABLE tempdb.[dbo].[temp_result]

    (

    [DATABASE_NAME] [nvarchar](128) NOT NULL

    ,[TableName] [sysname] ...

  • RE: Get Set For Speed

    Thank you Tom for this piece!

    😎

    After reading it I do have few concerns about the findings:

    1. The execution times suggest that a covering index for the aggregation is in place,...

  • RE: query for datetime

    charipg (12/28/2015)


    Hi,

    I need to set run time(dynamic) values for Startdate and Enddate in below query

    Enddate should be currentdate and Startdate should be minus 7 days of...

  • RE: Number VS Letter

    Forgot to post the implementation of the "digits only" logic as a subquery without the using a function, here is one that fits the previously posted test harness. This code...

  • RE: Covert columns to rows

    Quick solution

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    SELECT

    X.[DATABASE]

    ,X.[PARAMETER]

    ,X.[VALUE]

    FROM sys.databases SDB

    CROSS APPLY

    (

    ...

  • RE: Another XML explicit problem

    Quick suggestion, use FOR XML PATH rather than EXPLICIT

    😎

  • RE: Number VS Letter

    ScottPletcher (12/28/2015)


    I'd at least compare the performance of the straightforward brute-force method:

    The Chuck Norris/Brute-force method is many times slower apart from other limitations such as input length. For certain this...

  • RE: Get two sales item code exclusively from invoice

    Luis Cazares (12/28/2015)


    A small correction from Eirikur's code and two additional options.

    SELECT

    SI.invno

    FROM dbo.TBL_SALES_ITEMS SI

    WHERE SI.SIC IN ('111','222')

    GROUP BY SI.invno

    HAVING COUNT( DISTINCT SI.SIC)...

  • RE: The Most Common Query Blunders...

    Alan.B (12/28/2015)


    The most common/easiest to fix mistakes:

    Someone beat me to it but NOLOCK table hints are the #1 mistake I have seen. I would go so far as to say...

  • RE: To Get fixed periodic rownumbers by rounding the number to closest integer

    harishyarlagadda2020 (12/28/2015)


    Thank you Eirikur! I am using rownum% value= 0 rather than '<1'.

    This helped.

    You are very welcome.

    😎

  • RE: To Get fixed periodic rownumbers by rounding the number to closest integer

    Ed Wagner (12/28/2015)


    Nice job, Eirikur. I was working on the same approach, but was shooting for = 0 instead of < 1. The ceiling of the decimal division...

  • RE: To Get fixed periodic rownumbers by rounding the number to closest integer

    This is straight forward, select from the table where (Row_Number % Divisor) is less than one, rounding will not give the right results because of the loss of precicion.

    😎

    Quick sample

    ;WITH...

  • RE: The Most Common Query Blunders...

    Eric M Russell (12/28/2015)


    In addition to what's already been mentioned above:

    On the fly data type conversion and transformations, both explicit and implicit

    Distributed queries (ie: joining tables between multiple instances...

  • RE: Possible to insert unaffected by rollback?

    SQL Server is fully ACID (Atomicity, Consistency, Isolation, Durability), if you need functionality outside the ACID then use Jeff's suggestion and output the log to a file, that temp table...

  • RE: Get two sales item code exclusively from invoice

    Another wild guess

    😎

    USE tempdb;

    GO

    IF OBJECT_ID(N'dbo.TBL_SALES_ITEMS') IS NOT NULL DROP TABLE dbo.TBL_SALES_ITEMS;

    CREATE TABLE dbo.TBL_SALES_ITEMS

    (

    SI_ID INT IDENTITY(1,1) ...

Viewing 15 posts - 4,141 through 4,155 (of 8,761 total)