Forum Replies Created

Viewing 15 posts - 1,231 through 1,245 (of 1,404 total)

  • RE: Return some rows in columns

    WITH cteSports AS (

    SELECT * ,sn = ROW_NUMBER() OVER (PARTITION BY name ORDER BY sport)

    FROM #example

    )

    SELECT

    cte.name

    , cte.city

    , cte.entryDate

    , sport1 = MAX(CASE WHEN cte.sn =...

  • RE: Gracefully Handling CLR Function Problems

    When SQL processes a batch of records, it's an all or nothing process. If one of them has an error, all are aborted.

    The only way to do skip a...

  • RE: t-sql 2012 pick most current record

    Here are 3 different approaches that will acheive the same results

    -- Using cte with ROW_NUMBER

    WITH cte AS (

    SELECT CustID, PrintedDate, rn = ROW_NUMBER() OVER (PARTITION BY CustID ORDER...

  • RE: Header to Many rows

    Since your query does not have an ORDER BY clause, you are not guaranteed of any specific order.

    Perhaps adding the following to the end of your query will help

    ORDER BY...

  • RE: How to update column value

    spectra (1/5/2017)


    DesNorton (1/5/2017)


    INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)

    SELECT

    @_id,

    ROUND(CASE WHEN ta.const1 IS NULL OR ta.const1 != 0 THEN pd.COSTS_DST * ta.const1 / @const2

    ...

  • RE: How to update column value

    INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)

    SELECT

    @_id,

    ROUND(CASE WHEN ta.const1 IS NULL OR ta.const1 != 0 THEN pd.COSTS_DST * ta.const1 / @const2

    ...

  • RE: How to update column value

    spectra (1/5/2017)


    thats an impressive code !

    You are the SQL God.

    Thanks for the quick post.

    I am a relative noob, with sooo much to learn.

    Just glad I could be of help.

  • RE: How to update column value

    spectra (1/5/2017)


    Thank you.

    I wish to add one condition in my code i.e a zero value checking .

    like this ...

    if(@const1!=0)

    INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)

    SELECT

    @_id,

    COSTS_DST*@const1/@const2,

    'Y'

    FROM PRIOR_DIST

    WHERE _ID = @id_prev;

    else

    INSERT INTO...

  • RE: Trying to run TSQL queries with regular query in same SQMS querywindow

    You could also use a virtual tally table

    declare @startdate DATE = '2016-04-01'

    , @enddate DATE = '2016-04-30'

    ...

  • RE: How to update column value

    spectra (1/5/2017)


    DesNorton (1/5/2017)


    Is it possible to round the result up to 10 decimal place for the insert. Is there any way ?

    What is the datatype of COSTS_DST?

    If it is...

  • RE: How to update column value

    INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)

    SELECT

    @_id,

    COSTS_DST*@const1/@const2,

    'Y'

    FROM PRIOR_DIST

    WHERE _ID = @id_prev;

  • RE: replace null with another column

    Take a look at the COALESCE function

  • RE: Stored Procedure help

    ma701ss (1/3/2017)


    Forget returning the user id or data from any other columns, is it possible to amend the code to just return one value, i.e. either -2, -1 or 1?...

  • RE: Stored Procedure help

    It would appear that the [Id] field in AspNetUsers contains GUIDS.

    However, your proc declares @userid as INT, and then tries to assign a GUID to an INT...

  • RE: How to modify query to only use base tables

    Is product not possibly a view?

Viewing 15 posts - 1,231 through 1,245 (of 1,404 total)