Forum Replies Created

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

  • Reply To: First Time using SUBSTRING

    Fwiw, adding meta data like ('ORD'+number and 'MO'+date) to database keys is not the best practice.  If you're stuck with it perhaps it's possible to add constraints which only allow...

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

  • Reply To: Help needed in checking dates spans and status

    Isn't this the same question from 3 weeks ago?

    https://www.sqlservercentral.com/forums/topic/date-spans-for-continuoes-and-regular-dates-spans#post-3763906

    There were some good answers offered

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

  • Reply To: Unusual use of the WHERE clause

    Another way

    select s.salesman_id, s.salesman
    from
    #salesman s
    cross apply
    (SELECT COUNT(*) cnt FROM #customer c WHERE c.salesman_id=s.salesman_id) xa
    where
    xa.cnt>1;

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

  • Reply To: Unusual use of the WHERE clause

    drop table if exists #salesman;
    go
    create table #salesman(salesman_id int, salesman varchar(20));
    go

    insert #salesman(salesman_id, salesman) values
    (1, 'Tedd'),
    (2, 'Fred'),
    (3, 'Ed');

    drop table if exists #customer;
    go
    create table #customer(customer_id int, salesman_id int, customer...

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

  • Reply To: Ignoring error and continue

    roger.plowman wrote:

    Steve Collins wrote:

    roger.plowman wrote:

    My work is typically a .NET front end and SQL back end, so I favor having stored procedures fail and letting the front end handle the error.

    No...

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

  • Reply To: Ignoring error and continue

    Ok now it makes sense to me.   For some reason I thought the object_id() was going in the query and not the cursor.  In Azure SQL it's not allowed to...

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

  • 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

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