Forum Replies Created

Viewing 15 posts - 1 through 15 (of 394 total)

  • RE: SQL: Concatenate the rows based on Category and group by

    You can add as many CROSS APPLYs as you need.  If this is no good, post a more accurate example of your data.


    SELECT S.ID, S.Row_Desc,...

  • RE: SQL: Concatenate the rows based on Category and group by

    This will work.
    You can add extra CROSS APPLYs if needed...

    USE [tempdb]
    GO

    CREATE TABLE [Source]
    (
    ID Int,
    Row_Desc Char(1),
    Row_No Int,

  • RE: Unique ID for address field

    Try this:

    DROP TABLE #TEST

    CREATE TABLE #TEST ( Account Varchar(20), [Address] Varchar(50) )

    INSERT INTO #TEST
    VALUES
    ( 'Acme', '123 Acme Rd' ),
    (...

  • RE: Stored Procedure


    UPDATE T SET T.Amount = CASE
    WHEN T.[Type] = 'T' AND t.Period = 'Q' AND [Month] IN ( 3, 6, 9, 12 ) THEN ((T.Amount *...

  • RE: Query

    Hi

    How are you doing with this?

    There is no obvious reason for the sequencing you show:

    October 24, 2018 at 2:40 am

    #2010893

  • RE: STORE PROCEDURE SQL

    What language is this?  It doesn't look like TSQL...

  • RE: STORE PROCEDURE SQL

    Hi
    Where do you get the data used in inserting the records?  Does it come from parameters to the stored procedure?
    How do you tell if all Detail records have...

  • RE: Init-cap the characters in SQL server

    You could do this:

    SELECT UPPER(LEFT(Month_Name,1)) + LOWER(SUBSTRING(Month_Name,2,8))
    FROM abc

  • RE: Inserting recrods fromt the same table with an incremental value on every insert

    Try this:

    WITH CTE (SomeId, SomeType, SomeDesc) AS
    (
    SELECT 1, 'type', 'testing'
    UNION ALL
    SELECT 1, 'type', 'testing'
    UNION ALL
    SELECT 1, 'type', 'testing'
    UNION...

  • RE: sql trigger - if value equals a certain value then insert value in another table with same value

    OK.  I'm not sure it's a good idea, but try this:


    alter TRIGGER [dbo].[TRIGGER_STAGE_INSERT]
    ON [dbo].[AMGR_Opportunity_Tbl]
    after insert, update
    AS
    BEGIN
    DECLARE...

  • RE: sql trigger - if value equals a certain value then insert value in another table with same value

    Why don't you log it when it changes in Opportunity?

  • RE: sql trigger - if value equals a certain value then insert value in another table with same value

    I don't understand why you need to do this.

    If the value in O_Stage is the same as in Opportunity, why do you need to store it in O_Stage?

  • RE: Inserting recrods fromt the same table with an incremental value on every insert

    If you're adding one at a time you could do this:

    DECLARE @SomeID [int] = 1,
      @SomeType [nvarchar](5) = 'type',
      @SomeDesc [nvarchar](4000) =...

  • RE: Count values for first day of past n months

    Here are some options, getting to the final result in 3 stages to make it easier to understand. The third one should meet your requirements.
    You'll need to test it...

  • RE: sql trigger - if value equals a certain value then insert value in another table with same value

    It sounds as though you've got this back to front.
    Normally Table1 would be a look up of Opportunity Stages, with OppStage_Id & OppStage_Desc.
    When you create or update an...

  • Viewing 15 posts - 1 through 15 (of 394 total)