Forum Replies Created

Viewing 15 posts - 5,191 through 5,205 (of 10,144 total)

  • RE: Creating a Ref Number usning letters and numbers.

    Try this, Wayne:

    USE Occupancy

    ;WITH BookingsToUpdate AS (

    SELECT

    *,

    Seq = ROW_NUMBER() OVER (ORDER BY Booking_Skey)

    FROM Bookings

    )

    SELECT

    Seq,

    Booking_Skey,

    BookingNumber = 'B' + RIGHT('0000000' + CAST(Seq AS VARCHAR(8)),8),

    AnotherBookingNumber = 'B' + RIGHT('0000000'...

  • RE: Creating a Ref Number usning letters and numbers.

    wafw1971 (2/20/2013)


    I have a column on my database called Booking Number this is to be used on correspondence etc however I don't want it to be Booking Number to be...

  • RE: Creating a BookingDate using a random function

    wafw1971 (2/20/2013)


    Its alright I have figured it out:

    ...

    DwainC already figured it out for you:

    SELECT

    ArrivalDate,

    BookingDate = DATEADD(day,

    -(1 + ABS(checksum(NEWID())) % 90),

    ArrivalDate)

    FROM Bookings

    ORDER BY ArrivalDate

  • RE: Deleting duplicates rows

    DROP table #empl

    CREATE TABLE #empl

    (

    row_id int,

    ename varchar(120),

    job varchar(120),

    sal varchar(100)

    )

    INSERT #empl VALUES

    ('4','ram','IT','60000'),

    ('4','ram','IT','60000'),

    ('4','ram','IT','60000'),

    ('4','ram','IT','60000');

    WITH OrderedData AS (

    SELECT row_id, ename, job, sal,

    rn = ROW_NUMBER() OVER(PARTITION BY row_id, ename, job, sal...

  • RE: All Possible Combinations Loop

    akberali67 (2/18/2013)


    Chris, thanks again for all the help. Truly thanks doesnt do it but from the bottom of my heart I can not thank you for the help.

    Gosh - thanks!...

  • RE: SQL COMPARE HELP!!!

    -- Collect the matches

    SELECT l.ID ;

    FROM LARGE l ;

    INNER JOIN small s ;

    ON s.ID <> l.ID ;

    AND LARGE.Z5 = small.z5 and Large.ln = small.ln and Large.fn = small.fn...

  • RE: All Possible Combinations Loop

    Paul White (2/18/2013)


    ChrisM@Work (2/11/2013)


    I don't know if this error (Error 8623) is dependant upon system resources, in which case you might get lucky using a server with more resources, or...

  • RE: Any thoughts on this process?

    sqldba_newbie (2/16/2013)


    This is more of generic programming question. We have a stored procedure which is used on many of our applications built using asp.net. The sp basically first gives total...

  • RE: Need urgent help in a tricky t-SQL

    Sachin Vaidya (2/14/2013)


    Hi Cadavre,

    Your response definitely shows a path to move ahead, thanks a lot for that.

    But on the other side, it was very rude. It will discourage people from...

  • RE: A query question for the SQL Gurus

    Another way:

    SELECT abc.*

    FROM dbo.abc abc

    WHERE NOT EXISTS (SELECT 1 FROM dbo.xyz)

    OR abc.id IN (SELECT ID FROM dbo.xyz)

  • RE: Calculating a Moving Average

    mpdillon (2/12/2013)


    ...since it didn't use the lookup table, I was not able to fully implement it....

    Which lookup table, Pat? The article (and the discussion) should provide you with all the...

  • RE: Comparing figures based on relative date

    ScottPletcher (2/11/2013)


    For best performance,

    Cluster the table by

    LAST_DAY_OF_MONTH

    and not the dopey identity column. If you still need the identity (??), you can leave it as the nonclustered pk.

    +1

  • RE: IF or CASE on 2 different columns, THEN values x, y or z

    The option you have commented out will never be selected because there's an option before it in the CASE construct which will:

    CASE

    WHEN mb.name LIKE...

  • RE: Count Rows within a Query

    You're welcome. Thank you for the feedback.

  • RE: Change rows into column without using pivot method.

    gparamasivamit (2/11/2013)


    i need answer

    42 of course. Doesn't everybody know this now?

Viewing 15 posts - 5,191 through 5,205 (of 10,144 total)