Forum Replies Created

Viewing 15 posts - 151 through 165 (of 825 total)

  • RE: ShrinkFile

    BillLudlow - Wednesday, February 8, 2017 2:51 AM

    Is it that it releases the log space but doesn't change the physical file size? ...

  • RE: ShrinkFile

    t.franz - Wednesday, February 8, 2017 12:46 AM

    This is not true.
    I just used
    DBCC SHRINKFILE (N'mydb_log' , 0, TRUNCATEONLY)
    on my 4...

  • RE: Get the full name

    Uncomment the query you want to try:
    WITH Fullname
    AS
    (
    SELECT * FROM (VALUES
    ('Erin','Keri','Moody','Sr.')
    ,('Megan','Laura','Morales','B.S.')
    ,('George','Lena',NULL,'')
    ,(NULL,'Ryan','Lucas','M.D.')
    ,('Sheryl','Marianne','Morton','IV')
    ) AS V([firstname],[middlename],[lastname],[suffix])
    )
    --SELECT COALESCE
    --        (
    --        firstname,...

  • RE: Get the full name

    Julie Breutzmann - Wednesday, January 25, 2017 9:03 AM

    Steve Jones - SSC Editor - Tuesday, January 24, 2017...

  • RE: Get the full name

    hakan.winther - Wednesday, January 25, 2017 2:28 AM

    That was an easy one, thanks! You could also solve this query with CONCAT. 🙂

    That's...

  • RE: Char with null

    sendijunk (1/11/2017)


    Good question. Could use a bit more explanation though. Interesting what happens if you replace ISNULL with COALESCE.

    The return type depends on "precedence" of types. In this case, the...

  • RE: Query regression by index or statistics?

    Both filtered index and statistics suffer of parameterization in the where clause.

    In the following query, the optimizer can't predict which filtered statistic should be used (think to stored procs).

    declare @lan...

  • RE: GetDate() in blocked sessions

    The correct answer is "depend" on numbers of records in the table:

    With one or few records the correct answer is "09:00:10", but with many records (in my case 6800) the...

  • RE: Using Mod to Generate Work Shifts

    mlandry (12/22/2016)


    CHAR(...) + 65 is far too dependent upon the shift labels A, B, C. If they changed to non-contiguous strings, then this is out the window.

    Old "C" language trick.

  • RE: Using Mod to Generate Work Shifts

    Dohsan (12/22/2016)


    Could possibly remove the case

    CREATE FUNCTION [dbo].[ShiftCalc]

    (

    @ShiftTime DATETIME,

    @ShiftStart DATETIME,

    @NumOfShifts TINYINT

    )

    RETURNS TABLE WITH SCHEMABINDING

    AS

    RETURN

    SELECT

    OnShift = CHAR(ABS(DATEDIFF(DAY,@ShiftStart,DATEADD(HOUR,-DATEPART(HOUR,@ShiftStart), @ShiftTime))) % @NumOfShifts + 65);

    GO

    DECLARE @ShiftAStart DATETIME = '2006-01-01T07:00:00';

    SELECTD.Incident,

    CA1.OnShift

    FROM(

    VALUES(CAST('2006-01-01T07:00:00' AS DATETIME)),

    ('2006-01-01T17:00:00'),

    ('2006-01-02T06:00:00'),

    ('2006-01-02T07:00:00'),

    ('2006-01-02T23:00:00'),

    ('2006-01-03T07:00:00'),

    ('2006-01-03T09:00:00'),

    ('2006-01-04T07:00:00')

    ) AS D(Incident)

    CROSS

    APPLYdbo.ShiftCalc(D.Incident,@ShiftAStart,3) AS...

  • RE: Using Mod to Generate Work Shifts

    SET @compareDate = DATEADD(HOUR, -7, @ShiftDate)

    SELECT CASE ABS(DATEDIFF(DD, @compareDate, @baseDate)) % 3

    WHEN 0 .....

  • RE: The autogenerated view

    Thanks! I learned a real new and interesting feature!

  • RE: The inline TVF

    Any select could be surrounded by parenthesis:

    (select * from sys.objects WHERE name like 'sys%')

    (select * from sys.indexes WHERE name like 'c%')

  • RE: The inline TVF

    I love a lot the inline TVF.

    😛

  • RE: Performing union data with null values

    Stewart "Arturius" Campbell (11/14/2016)


    Interesting question, thanks Junior.

    However, as I am sure you are aware, the sequence is important:

    if the query is changed toSELECT 0

    UNION

    SELECT 1

    UNION

    SELECT NULL

    UNION ALL

    SELECT NULL

    UNION

    SELECT 2;, the...

Viewing 15 posts - 151 through 165 (of 825 total)