Forum Replies Created

Viewing 15 posts - 991 through 1,005 (of 1,413 total)

  • Reply To: Ignoring error and continue

    schleep, that sounds interesting.  It's a 3 part naming convention?  Is there a . missing before dbo.?  Maybe it's simpler to query the sys table and idk.  It could be...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Ignoring error and continue

    Thanks Roger.  Regarding "Errors Unaffected by a Try/Catch Construct" the issues are mitigate-able (imo (all of what follows)) if handled properly (knock on wood).  I must be biased tho because...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Ignoring error and continue

    schleep wrote:

    Declare @msg varchar(100)

    DECLARE db_cursor CURSOR FOR

    SELECT Name FROM Alldatabases

    WHERE OBJECT_ID(Name + 'dbo.<tablename>') IS NOT NULL

    ORDER BY Name

    OPEN wh_cursor

    In your post, you had 2 tables, Settings and Employee, so maybe...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Ignoring error and continue

    roger.plowman wrote:

    TRY/CATCH doesn't catch everything. In fact it won't catch most of the things you really want it to so I simply avoid it completely. Nothing worse than an unreliable...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: gender breakdown sp

    select 
    a.[name],
    sum(iif(b.gender='M', 1, 0)) m_count,
    sum(iif(b.gender='F', 1, 0)) f_count
    from
    #department a
    join
    #employee b on a.departmentID = b.departmentID
    group by
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How to return lowest level parts from BOM

    .

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Ignoring error and continue

    There's a lot going on in the code which could be looked at.  Instead of EXEC(@qry) where the parameters are strung together it could be parameterized using sp_executesql.  In terms...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Ignoring error and continue

    To get SQL Server to ignore and continue is possible from a script or procedure by executing another (or more...) stored procedure which contain try/catch where the error is output...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help in Date spans for continuoes and regular dates spans

    ChrisM@Work wrote:

    Can you write it without the function?

    In theory it should be possible but maybe not easily.  The tvf is parameterized so I think to remove it would require splitting...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help in Date spans for continuoes and regular dates spans

    The query could be without the cte

    select
    t1.id, cast(t1.startdate as date) startdate, cast(t1.enddate as date) enddate, cast(td.enddate as date) range_end_dt
    from
    dbo.test_1 t1
    cross apply
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help in Date spans for continuoes and regular dates spans

    The OP wrote: "output is expected as if member is continuously enrolled without any gap in enrollment get min and max and if there is enrollment gap leave as is." ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help in Date spans for continuoes and regular dates spans

    To resolve for arbitrary relationships in the data requires hierarchical recursion, no?  The OP's question and Phil's too

    drop table if exists dbo.test_1;
    go
    create table dbo.test_1(id int,startdate datetime ,enddate...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sum query

    drop table if exists dbo.test_T1;
    go
    create table dbo.test_T1(
    ID1 varchar(8) not null,
    ID2 varchar(8)...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: UTC time to EST time

    In 2016 there are some nice built in features to support time zone conversions

    /* the list of time zones your instance supports */
    select * from sys.time_zone_info;

    declare
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Query

    this

    declare @frDate         date='2020-03-31';

    with a_cte(DocType, Debit, Credit, Account, Mdate) as
    (select 'TC', 10, 20, 123, '2020-03-30'
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 991 through 1,005 (of 1,413 total)