Forum Replies Created

Viewing 13 posts - 1 through 14 (of 14 total)

  • Reply To: Fire Triggers option not available in SSIS package

    Hi, I have included FIRE_TRIGGERS in fast load mode and my package is failing with error "An error was raised during trigger execution. The batch has been aborted and the...

  • Reply To: how to create triggers with delete and update

    Remove duplicates using CTE as below and then you can insert records as per your existing process.

    --Removing duplicates

    ;WITH Duplicates AS (

    SELECT

    OrderId,OrderDate,OrederArea,OrderCode,

    ROW_NUMBER() OVER (

    PARTITION BY

    OrderId,OrderDate,OrederArea,OrderCode

    ORDER BY

    CreateDate desc

    ) row_num

    FROM

    temp.Order

    )

    delete from Duplicates WHERE...

  • Reply To: Union with temp table

    I dont think there are duplicates in your result set. However, You can use the below:

    Select A.* Into #temp From (

    <<Your code>>

    ) As A Where A.DetailId Not In(Select DetailId From...

  • Reply To: "Conversion failed when converting the varchar value to data type int

    StrutturaOrganizzativa.descrizione is string type and Negozi.fk_responsabile is integer type. When you join on two columns both should be of same datatype. Use this:

    Select

    Negozi.descrizione,

    StrutturaOrganizzativa.descrizione

    from Negozi

    inner join StrutturaOrganizzativa

    on StrutturaOrganizzativa.pk_id = Negozi.pk_id

  • Reply To: Select last non null value in field

    You can achieve this by using the following SQL:

    Select unit.rptMth as [Date],

    COALESCE(NULLIF(unit.Buiding,''),x.Buiding) as Building,

    COALESCE(NULLIF(unit.Unit,''),x.Unit) as Unit,

    NULLIF(unit.uStatus,'') as RentStatus,

    COALESCE(nullif(unit.uStatus, ''), x.uStatus) DesiredStatus

    From #tmpFUnit unit

    Outer Apply (Select Top 1 Buiding, Unit, uStatus

    From...

  • Reply To: result in same line

    Just remove status from select clause and see.

    • This reply was modified 6 years, 6 months ago by Sumathi.
  • Reply To: SENDING THE RESULTS OF A SELECT STATEMENT FROM A #TEMP TABLE WITH Sp_Send_dbMail

    You can use the below T-SQL:

    DECLARE @email_addr NVARCHAR(450), @min_id int, @max_id int, @query NVARCHAR(1000)

    SELECT @min_id=MIN(id), @max_id=MAX(id) FROM #YourTable

    WHILE @min_id<=@max_id

    BEGIN

    SELECT @email_addr=email_addr FROM #YourTable

    set @query='sp_send_dbmail @profile_name=''ProfileName'',

    @recipients='''+@email_addr+''',

    @subject=''subject line'',

    @body=''Body message.'''

    EXEC @query

    SELECT @min_id=MIN(id) FROM #YourTable...

  • Reply To: Need help on ssrs report parameters or expression

    Set a default value to the parameter and validate against that default to identify blanks.

  • Reply To: A bit of mathematics...

    Perfect.

    IIF makes it easy 🙂

  • Reply To: SQL Query with CTE or other...!

    You can achieve this using the below query:

    SELECT ID, Question, [A], , [C], [OPTION]

    FROM

    (

    SELECT A.ID,Answer,Question

    FROM Answer A

    inner join Question Q on A.ID = Q.QuestionID

    ) As PivotTable

    PIVOT

    (

    MAX(Answer)

    FOR Answer IN ([A], ,...

  • Reply To: Parsing SQL Data between Tables for a certain Output

    You can do this using Joins as below:

    --Inner join for exact match between INFO and MATION

    Select i.Name, i.Age, m.Description IDNumber

    From INFO i

    Inner join MATION m on i.IDNumber = m.ID

    --Left Outer...

  • Reply To: SQL query help

    You can use this one

    substring(col_processing, PatIndex('%[0-9]%', col_processing), len(col_processing))+1

  • Reply To: select several lines randomly according to several categories

    This can be done using

    SELECT TOP (@rows) y.Family, y.Room, y.subfamily

    FROM @Table AS y

    ORDER BY NEWID();

    OR

    SELECT y.Family, y.Room, y.subfamily

    FROM @Table AS y TABLESAMPLE(3 ROWS)

    But, the TABLESAMPLE clause cannot be applied to...

Viewing 13 posts - 1 through 14 (of 14 total)