Forum Replies Created

Viewing 15 posts - 5,551 through 5,565 (of 7,608 total)

  • RE: Find Appropriate Event After An Incident

    First thing is to get the best clustering:

    Cluster the violation table on ( OrderID, StartDate )

    Cluster the sanction table on ( OrderID, IdentifiedDate )

  • RE: Conversion failure varchar to int

    Might as well handle any db and any schema, but defaulting to your main one.

    CREATE PROC CLEAR_MY_TABLE

    @TableStat varchar(100)

    AS

    SET NOCOUNT ON;

    DECLARE @TableStat varchar(100)

    SET @TableStat = ISNULL(PARSENAME(@TableStat, 3),...

  • RE: truncate table not good idea for production

    Truncating tables is a great idea when applicable. It's vastly less logging overhead than deleting all the rows instead. Dropping the table and recreating is also more overhead...

  • RE: Cannot open user default database. Login failed.

    This query will find logins with a default db that is not online, and show any job(s) that login owns.

    select sp.*, j.*

    from sys.server_principals sp

    left outer join msdb.dbo.sysjobs j on

    ...

  • RE: Digits only

    It's only 20 chars, I'd do it as simply as possible rather than over-complicate it:

    SELECT MP.RefNum, MP.Phone,

    CASE WHEN SUBSTRING(MP.Phone, 01, 1) LIKE '[0-9]' THEN SUBSTRING(MP.Phone,...

  • RE: create trigger on update and on insert

    If you just want to do INSERTs to the other table, and not UPDATEs:

    CREATE TRIGGER trigger_name

    ON dbo.CARTOES

    AFTER INSERT, UPDATE

    AS

    SET NOCOUNT ON;

    INSERT INTO dbo.another_table --(column_name1, column_name2, ...)

    SELECT

    [COD_ID],

    [CODCTB],

    [NIFCTB],

    [NOMECTB],

    [DT_EMISSAO],

    [DT_VALIDADE],

    [DT_ANULACAO],

    [DESCR_REP_FISCAL],

    [NUMCARTAO],

    [STATUS],

    [UTILIZADOR]

    FROM inserted

    GO

  • RE: "Remove Clutered property" from PK

    PiMané (12/16/2014)


    ScottPletcher (12/16/2014)


    Is there any easy way to determine what FKs are "hanging" on the PK?

    Yes, using view "sys.foreign_keys", and, if needed, "sys.foreign_key_columns" as well.

    that's what i'm currently doing...

    select the...

  • RE: Question regarding mdf and ldf file on a separate drives.

    Yes, you need separate physical drives.

    Smaller, cheaper drives very often work better than a single, more expensive drive. For I/O, the number of spindles is more critical than the...

  • RE: Creating an alphabetical list with letter header

    Yes, UNION in "A", "B", "C", ..., "Z" to the source table and then sort it, something like this:

    SELECT name

    FROM table_name

    UNION ALL

    SELECT v.letter

    FROM (VALUES('A'),('B'),('C')) AS v(letter)

    ORDER BY name

  • RE: "Remove Clutered property" from PK

    Is there any easy way to determine what FKs are "hanging" on the PK?

    Yes, using view "sys.foreign_keys", and, if needed, "sys.foreign_key_columns" as well.

  • RE: Find All Compressed tables in database - script

    FYI:

    WHERE sp.data_compression > 0

    is more sargable then "<> 0"; avoid <> unless you have to use it.

  • RE: Fragmented Index - Zero Usage - Zero Updates

    Maybe you could DISABLE the indexes if they are truly never used?

  • RE: A significant part of sql server process memory has been paged out

    If the server has only 2GB, then you'll have to limit SQL to 1.5GB. Otherwise it will use it all, causing serious memory problems. Yes, you almost certainly...

  • RE: Year summary report

    If you want to load variables, then as below. If you just want to list each month, remove the "@Jan = " and put " AS Jan" after the...

  • RE: Database connection permissions

    You can give them separate permissions in msdb to deal with jobs.

    I can't imagine why you would want people arbitrarily creating maintenance plans, but you should be able to add...

Viewing 15 posts - 5,551 through 5,565 (of 7,608 total)