Forum Replies Created

Viewing 15 posts - 691 through 705 (of 1,491 total)

  • RE: Error Restoring Database including Trasaction Log

    To avoid typos when replacing DBs from backups with the same logcal file names, I tend to generate the MOVEs with the following:

    -- To generate MOVEs from dest DB

    SELECT ',MOVE...

  • RE: Weird slowdown issue, possible table lock

    My experience is that JOINs in sub-queries soon become nested loops.

    Also, using EXISTS sub-queries negates the need for a DISTINCT.

    I would try something like:

    WITH UpdID

    AS

    (

    SELECT ID

    FROM demogtable d1

    WHERE d1.demogID =...

  • RE: good book for temporal db design?

    This is also quite old but worth reading:

    http://www.cs.arizona.edu/~rts/tdbbook.pdf

  • RE: Extracting files from "binary" stored in TEXT datatype

    Your key problem will be working out what the encoding is.

    It is probably Base64. This site may help:

    http://www.opinionatedgeek.com/dotnet/tools/base64decode/

  • RE: BEGIN TRY - Catch not working

    I think sp_start_job is one of the SPs which do not throw errors but return a status code instead.

    Try:

    DECLARE @RetVal int;

    EXEC @RetVal = msdb.dbo.sp_start_job N'TestJob';

    IF @RetVal > 0

    RAISERROR(N'TestJob failed to...

  • RE: Optimizing the data

    Using the Windowed functions (ROW_NUMBER, RANK etc), is normally the easiest way to resolve this type of query.

    -- *** Test Data ***

    -- You should provide test data in this format...

  • RE: Lock escalation concept

    Locks are acquired by a SQL connection.

    If one connection acquires an X lock on a table that connection can still do a SELECT; it is just other connections that will...

  • RE: Query Help

    CREATE TABLE dbo.MyTable

    (

    MasterIp varchar(255) NOT NULL

    CONSTRAINT PK_MyTable PRIMARY KEY

    ,status1 tinyint NOT NULL

    ,status2 tinyint NOT NULL

    ,Active_status tinyint NOT NULL

    )

    GO

    CREATE TRIGGER TR_MyTable_IU

    ON dbo.MyTable

    AFTER INSERT, UPDATE

    AS

    IF @@ROWCOUNT = 0 RETURN;

    SET NOCOUNT ON;

    -- Rows...

  • RE: Comparing the dates on multiple rows

    I do not understand your results, but the following should get you started:

    -- *** Test Data ***

    CREATE TABLE #t

    (

    TransactionId int NOT NULL

    ,SellDateTime datetime NOT NULL

    );

    INSERT INTO #t

    VALUES (1, '20120612 09:30')

    ,(2,...

  • RE: Multiple Row Update in Triggers

    ALZDBA (4/18/2012)


    keep in mind to also check your inserted set for duplicates.

    I was half thinking that for my original version but of course it is an AFTER trigger so one...

  • RE: Multiple Row Update in Triggers

    The trigger should be:

    SET ANSI_NULLS, QUOTED_IDENTIFIER ON

    GO

    ALTER TRIGGER dbo.TR_tblProduct_PRCode

    ON dbo.tblProduct

    AFTER INSERT,UPDATE

    AS

    SET NOCOUNT ON;

    BEGIN TRY

    IF EXISTS

    (

    SELECT 1

    FROM inserted

    WHERE COALESCE(PRCode, '') = ''

    )

    RAISERROR ('No PR Code.', 17,1);

    IF EXISTS

    (

    SELECT P.PRCode

    FROM dbo.tblProduct P

    WHERE...

  • RE: Multiple Row Update in Triggers

    SET ANSI_NULLS, QUOTED_IDENTIFIER ON

    GO

    --CREATE TABLE dbo.Exceptions

    --(

    --ExceptionId int IDENTITY(1,1) NOT NULL

    --CONSTRAINT PK_Exceptions PRIMARY KEY

    --,ExceptionDate datetime NOT NULL

    --,ErrorNumber int NOT NULL

    --,ErrorSeverity int NOT NULL

    --,ErrorState int NOT NULL

    --,ErrorProcedure nvarchar(126) NOT NULL

    --,ErrorLine int NOT...

  • RE: Database Backup via T-SQL

    I am not sure if this process this is a good idea. (Data security etc)

    If you really want to do it, you could look at creating a job on the...

  • RE: T SQL joins to ansi sql joins conversion

    The way to do these conversions is to follow the WHERE clause and remember that the *, in the *=/=*, is against the table where all the rows are to...

  • RE: Data Gravity

    david.moule (3/7/2012)


    In Europe, at least, I think the law states something like personal data cannot be physically or electronically transferred to another non-EU country. So for the EU countries,...

Viewing 15 posts - 691 through 705 (of 1,491 total)