Forum Replies Created

Viewing 15 posts - 706 through 720 (of 1,497 total)

  • 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,...

  • RE: CHARINDEX problem

    I suspect your problem is with DATALENGTH.

    Try using varchar(MAX) instead of text and simplifying your expressions.

    (You do not need the length of the substring, just any number greater than its...

  • RE: TSQL to return column headers (but no rows)

    If only the metadata is required by an application, then use:

    SET FMTONLY ON;

  • RE: select Query Issue

    Or a more simplistic approach...

    -- *** Test Data ***

    CREATE TABLE #t

    (

    ID int NOT NULL

    ,PID int NOT NULL

    ,[Name] varchar(25) NOT NULL

    )

    INSERT INTO #t

    SELECT 1, 0, 'Ad'

    UNION ALL SELECT 2, 0, 'Area'

    UNION...

  • RE: Division problem

    Zero is the correct answer as an integer divided by an integer is an integer.

    If you want a floating point answer, make one for the constants a float.

    eg SELECT 1.0/6;

    Edit...

  • RE: Fetchinh the Total Count based on the Date Time

    I think you are going to have to calculate the hour and minute values separately and then combine them.

    You will probably have to use both a Calendar and a tally...

  • RE: Last 5 rows

    Charmer (11/16/2011)


    Random Order...!!!?

    but how come it gives same records every time when we execute the query..?

    it must change the order right?

    Under some curcumstances the order of a select statement,...

  • RE: Identify first complete sequence

    I am not sure why ID is in your test data, but something like the following may help:

    -- *** Test Data ***

    CREATE TABLE #t

    (

    ReturnDate datetime NOT NULL

    )

    INSERT INTO #t

    VALUES ('20101031')

    ,('20101130')

    ,('20110131');

    --...

  • RE: Collation Sequence difference between table variables and temp tables

    The best way to ensure the correct collation for a temp table is to always use SELECT INTO to create them.

    (This also has the advantage that if the column width...

Viewing 15 posts - 706 through 720 (of 1,497 total)