Forum Replies Created

Viewing 15 posts - 1,006 through 1,020 (of 1,494 total)

  • RE: Facing Query OutPut Performance problem using view

    Why not just pass name to your function? The function will then not need to do a lookup.

  • RE: Split Time Records

    You should derive the shifts from a Calendar table and then join to your data.

    (Look up Calendar table on this site)

    For simplicity I have just used a shifts table here:

    DECLARE...

  • RE: Performance Problem

    Also, are there any user defined functions in the query?

  • RE: Updating a column with serial numbers

    You can update a derived table:

    UPDATE D

    SET seqCol = RowId

    FROM

    (

    &nbsp&nbsp&nbsp&nbspSELECT ROW_NUMBER() OVER (PARTITION BY FK_ID ORDER BY CreationDate) AS RowId

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp,seqCol

    &nbsp&nbsp&nbsp&nbspFROM tab1

    &nbsp&nbsp&nbsp&nbspWHERE FK_ID = 6

    ) D

  • RE: Correlated Sub Query (RBAR WTF?)

    My experience of joins in subqueries is that they always end up as nested loops. This can be very inefficient with large tables. (Check your query plans to confirm this.)

    I...

  • RE: Help with a complex sql

    OR (ISNULL(NULLIF(T.Id1, ''), 0) AND ... )

  • RE: Troublesome Update statement

    On the information you have given us so far 23000 is the correct number of rows to be updated.

    Plug your query into the following test data, look at the results...

  • RE: Troublesome Update statement

    This is a classic example of why you should not use TSQL type UPDATEs unless you know

    what you are doing. (We insist on ANSI UPDATEs in production code unless a...

  • RE: Trigger

    I suspect you should be doing something with the inserted pseudo-table.

    If the primary key on CANDIDATE is candidateId then something like:

    SET QUOTED_IDENTIFIER, ANSI_NULLS ON

    GO

    ALTER TRIGGER dbo.CC_TR_CANDIDATE_PF

    ON dbo.CANDIDATE

    AFTER UPDATE

    AS

    BEGIN

    &nbsp&nbsp&nbsp&nbspSET NOCOUNT...

  • RE: Help with a complex sql

    Did you run the OR (T.Id1 = 0 AND T.Id2 = 0 AND T.Id3 = 0) part of the query?

  • RE: update problem in cicle

    At a guess:

    UPDATE mandiflex.dbo.TABATOPCO

    SET U_NCONSUMO = 1

    WHERE EXISTS

    (

    &nbsp&nbsp&nbsp&nbspSELECT *

    &nbsp&nbsp&nbsp&nbspFROM mandiflex.dbo.tabat T

    &nbsp&nbsp&nbsp&nbspWHERE EXISTS

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp(

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSELECT *

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFROM prodiflex.dbo.st S

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWHERE T.cod_art = S.ref

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspAND S.familia ='MP208'

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp)

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp-- assumming link between tabat and TABATOPCO is st_tabatphc in both...

  • RE: Help with a complex sql

    -- *** Test Data ***

    DECLARE @t TABLE

    (

    &nbsp&nbsp&nbsp&nbspsrno int NOT NULL

    &nbsp&nbsp&nbsp&nbsp,FName varchar(20) NOT NULL

    &nbsp&nbsp&nbsp&nbsp,LName varchar(20) NOT NULL

    &nbsp&nbsp&nbsp&nbsp,dob datetime NOT NULL

    &nbsp&nbsp&nbsp&nbsp,batch varchar(10) NOT NULL

    &nbsp&nbsp&nbsp&nbsp,Id1 int NOT NULL

    &nbsp&nbsp&nbsp&nbsp,Id2 int NOT NULL

    &nbsp&nbsp&nbsp&nbsp,Id3 int NOT...

  • RE: How to split on a double quote

    -- *** Test Data ***

    DECLARE @t TABLE

    (

    &nbsp&nbsp&nbsp&nbspLine varchar(50) NOT NULL

    )

    INSERT INTO @t

    SELECT 'UserLogon Logon "Domain\Username" from blah' UNION ALL

    SELECT 'Junk' UNION ALL

    SELECT '"Junk2' UNION ALL

    SELECT 'UserLogon Logon "Domain\Username2"'

    -- *** End...

  • RE: Removing Duplicates with condition - Help

    SELECT Acno, [Date], NodeName

    FROM

    (

    &nbsp&nbsp&nbsp&nbspSELECT ROW_NUMBER() OVER (PARTITION BY AcNo ORDER BY [Date] DESC) AS RowId

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp,Acno, [Date], NodeName

    &nbsp&nbsp&nbsp&nbspFROM YourTable

    ) D

    WHERE RowId = 1

    ORDER BY AcNo DESC

  • RE: Inserting records from multiple tables

    Derek – sorry for the confusion but my question was aimed at the OP as he seemed to be relying on the order the data was placed in the tables.

    My...

Viewing 15 posts - 1,006 through 1,020 (of 1,494 total)