Forum Replies Created

Viewing 15 posts - 2,611 through 2,625 (of 3,957 total)

  • RE: Need to fill the Gaps with previous value

    I like your:

    VALUES ($)

    Wonder where you got that from... 😛

  • RE: Script to find incorrect data in all tables

    Here's something that might get you started:

    ;WITH NullableColumns AS (

    SELECT TableName=a.name, ColName=b.name

    FROM QA.sys.objects a

    INNER JOIN QA.sys.all_columns...

  • RE: Need to fill the Gaps with previous value

    ChrisM@Work (10/8/2012)


    dwain.c (10/8/2012)


    ChrisM@Work (10/8/2012)


    Hi Dwain, I came up with this last night but ran out of time to post;

    ;WITH WholeRange AS (

    SELECT datecol = DATEADD(day,n,d.Startdate)

    FROM (SELECT Startdate = MIN(datecol), daysSpan...

  • RE: Need to fill the Gaps with previous value

    ChrisM@Work (10/8/2012)


    Hi Dwain, I came up with this last night but ran out of time to post;

    ;WITH WholeRange AS (

    SELECT datecol = DATEADD(day,n,d.Startdate)

    FROM (SELECT Startdate = MIN(datecol), daysSpan = 1+DATEDIFF(day,MIN(datecol),...

  • RE: Need to fill the Gaps with previous value

    Jeff Moden (10/7/2012)


    Nagaram (10/7/2012)


    Here is the another solution ;

    ;WITH DigitsCTE AS

    (

    SELECT digit

    FROM (VALUES(0), (1), (2), (3), (4), (5), (6), (7), (8), (9))...

  • RE: Need to fill the Gaps with previous value

    I find it extremely annoying that this does not work:

    DECLARE @Weight FLOAT = 0

    ,@STDate DATETIME

    ,@EDate DATETIME

    SELECT @STDate=MIN(DATECOL), @EDate=MAX(DATECOL) FROM #SAMPLETABLE

    ;WITH Tally...

  • RE: Transposing, filtering, most recent record

    midavalo (10/7/2012)


    dwain.c (10/7/2012)


    First of all, it would be most useful if you put your sample data into consumable form and provide DDL, e.g.:

    Excuse my ignorance, but what is DDL?

    Cheers,

    Mike.

    DDL=DATA DEFINITION...

  • RE: Need to fill the Gaps with previous value

    Jeff Moden (10/7/2012)


    dwain.c (10/7/2012)


    I don't think this has the same issue that Jeff is reporting about Mark's but it's just another option:

    Gosh. Good bit of code, Dwain, but it...

  • RE: Transposing, filtering, most recent record

    First of all, it would be most useful if you put your sample data into consumable form and provide DDL, e.g.:

    DECLARE @t TABLE (col1 VARCHAR(10), col2 VARCHAR(10))

    INSERT INTO @t

    SELECT 'abc',...

  • RE: Using case in updating column

    Is there some reason you can't or won't use a MERGE for this?

    CREATE TABLE #Weights

    (id INT, shipweight1 DECIMAL(5,2)

    ,shipweight2 DECIMAL(5,2), shipweight3 DECIMAL(5,2))

    INSERT INTO...

  • RE: Need to fill the Gaps with previous value

    I don't think this has the same issue that Jeff is reporting about Mark's but it's just another option:

    ;WITH Tally AS (

    SELECT...

  • RE: T-sql select - like

    gravitysucks (10/5/2012)


    AND SUBSTRING(LastName,1,1)<>'/' ---??

    Yes or:

    AND LEFT(LTRIM(LastName), 1) <> '/'

    The LTRIM is in case there are blanks only leading up to the slash.

  • RE: query to count repating alphabet in a string

    ChrisM@Work (9/21/2012)


    Big hammer;

    DECLARE @asd VARCHAR(20)

    SET @asd = 'asdaaaadffa'

    SELECT

    Letter,

    Occurrences = COUNT(*)

    FROM (

    SELECT Letter = SUBSTRING(@asd,n,1)

    FROM (SELECT TOP(LEN(@asd)) n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL))

    FROM sys.all_columns) tally

    ) d

    GROUP BY...

  • RE: Need help with trigger

    Lowell (10/4/2012)


    I have this saved as a handy auditing snippet;

    all these variables are available in 2008 and above, so if you have an audit table, just include some columns for...

  • RE: loop and insert

    venus.pvr (10/4/2012)


    Not sure if the order of the inserts matter. Else the below would work:

    DECLARE @a INT

    SELECT @a=MAX(empid)+99 FROM dbo.employee

    INSERT INTO dbo.employee(empid,name,city)

    SELECT @a+ROW_NUMBER() OVER (ORDER BY name),name,city FROM #newuser

    -Praveena

    I would...

Viewing 15 posts - 2,611 through 2,625 (of 3,957 total)