Forum Replies Created

Viewing 15 posts - 856 through 870 (of 13,465 total)

  • RE: SQL database files

    tobypaul509 (8/23/2016)


    What is the best tool in terms of efficiency, cost and success rate for repairing and recovering corrupt SQL 2005 database files?

    I need to purchase a tool for my...

  • RE: How to prevent a table from being truncated or dropped

    ChrisM@Work (8/23/2016)


    JasonClark (8/23/2016)


    Try to run the below code to prevent accidental delete:

    CREATE TRIGGER [TR_ProtectCriticalTables]

    ON DATABASE

    FOR

    DROP_TABLE

    AS

    DECLARE @eventData XML,

    @uname NVARCHAR(50),

    ...

  • RE: Extended Event DDL and Filter out Temp tables?

    GilaMonster (8/22/2016)


    Try filtering on database_id, or is the db_id the id of the connection rather than the table?

    doh simple and obvious;

    the database_id =2 , regardless of what database context that...

  • RE: Execution Plan Question

    whenever the difference between estimated rows and actual rows is off by a lot(order of magnitude or more,

    it usually means the statistics are out of date enough to adversely affect...

  • RE: SQL backup Script is appending instead of overwriting

    it's an easy fix.

    change the NOINIT TO INIT

    that is append vs create/overwrite.

    mwinn (8/11/2016)


    I have been running this Backup script for several years but yesterday I had to transfer the database...

  • RE: Replace commas from all columns in a Table (Just one table)

    the data is the data. don't modify the data, modify the query that is exporting to csv.

    if you use SSIS, you can modify it to export everything with double...

  • RE: Rename Column with comma

    i think you want something like this:

    SELECT

    'exec sp_rename ''' + QUOTENAME(Table_Name) + '.' + QUOTENAME(REPLACE(COLUMN_NAME,'''','''''')) +

    ''', ''' + QUOTENAME(LOWER(REPLACE(COLUMN_NAME,'''',''''''))) + ''', ' + '''COLUMN'';'

    FROM

    Information_Schema.[COLUMNS]

    WHERE COLUMN_NAME <>...

  • RE: Rename Column with comma

    any object name with a single quote in it needs to be escaped in a command:

    exec sp_rename '[table_name].[Rec''d 2007]', '[rec''d 2007]', 'COLUMN';

  • RE: t-sql 2012 use a trigger

    TheSQLGuru (8/7/2016)


    If you do this with a trigger, you MUST make it asynchronous!! I would either put the necessary information into a simple queue-style table or use SQL Server Service...

  • RE: t-sql 2012 use a trigger

    Does the existence of duplicates actually break anything, or is it just a cleanup task because the .net application doesn't check for duplicates before adding the data? the urgency is...

  • RE: ISNULL function does not allow concatenating CHAR's in SQL 2008R2 or earlier

    wow Line 74851

    thats a huge proc to debug.

    at that size, it must be doing a zillion things, that's rough.

  • RE: Linked Server Update "Hung"

    i think it would be like this, right?

    DECLARE @TermToTweak VARCHAR(30) = 'lowell@fake.com'

    DECLARE @cmd VARCHAR(MAX) = 'EXECUTE AT(LinkedServer,''update P

    set P.Email1 = ''' + @TermToTweak + '''

    from MyDatabase.dbo.Profiles P

    JOIN MyDatabase.dbo.Complaints C on...

  • RE: Linked Server Update "Hung"

    homebrew01 (7/29/2016)


    I am doing a pretty simple update of Table_A, based on a join to Table_B

    The query runs on Server_A, via Linked Server to Server_B, where both tables reside.

    If I...

  • RE: Update all fields in a record except incoming NULL values?

    probably with a CASE statement;

    something like this in your proc(assuming parameters are available for all four fields you mentione:

    update Table1

    SET Field1 = CASE WHEN @Field1 IS NULL THEN Field1...

  • RE: Migration to Azure - FillFactor needs to be removed on 200+ indexes

    i use this to script out indexes,

    I just tested it an Azure, no problems, of course.

    i've excluded fillfactor in it, you could tweak the statement generation to whatever you...

Viewing 15 posts - 856 through 870 (of 13,465 total)