Forum Replies Created

Viewing 15 posts - 136 through 150 (of 321 total)

  • RE: Please help in this trigger!!!

    CREATE TRIGGER INS_tblmembers

    ON tblmembers

    FOR INSERT

    AS

    INSERT INTO TX_tblmembers

    Select ID, fname, lname, address,newid(),'i',getdate(),0 from inserted

     

    CREATE TRIGGER DEL_tblmembers

    ON tblmembers

    FOR DELETE

    AS

    INSERT INTO TX_tblmembers

    Select ID, fname, lname, address,newid(),'d',getdate(),0 from...

  • RE: Question on SQL sp getting correct results back

    You can eliminate your cursor

     

    SET @SQLStr = 'SELECT rpt.pagetype, rpt.PageFontColor, rpt.PageTypeAbbrev, count(rh.Project_requestheader_pkey) as TotalPagetype, p.projects_pkey'

    SELECT @SQLStr = @SQLStr + ',SUM(CASE WHEN pl.ProjLegend_abbrev= ''' + PageTypeAbbrev + '''

      THEN 1...

  • RE: Need Help by Update Table !

    From your sample data you are missing the acdkennung table.

    Also you have too many rows. To provide a good sample just give an example with a few rows ... 5-...

  • RE: Need Help by Update Table !

    This can be replaced

     

    --8. look for time changes on the schedule

    CREATE TABLE #tcs

    (

    personalnummer int default null,

    agentname char (30)default null,

    eintrittsdatum char(20)default null,

    datum char(20)default null,

    code char(10)default null,

    start_moment datetime default null,

    stop_moment datetime default...

  • RE: Need Help by Update Table !

    SELECT distinct t1.personalnummer,t1.agentname,t1.eintrittsdatum,

    t1.datum,t1.code,t1.start_moment,t2.stop_moment,t1.groupid

    FROM svtcs T1 JOIN svtcs T2 ON (t1.personalnummer=t2.personalnummer)

    WHERE t1.stop_moment =

    (SELECT MAX(t3.stop_moment)

    FROM svtcs T3

    WHERE (t3.personalnummer=t1.personalnummer)

    AND t3.stop_moment =t2.start_moment)

    if it is K than you can ELIMINATE the...

  • RE: Need Help by Update Table !

    INSERT INTO #tcs

    SELECT distinct t1.personalnummer,t1.agentname,t1.eintrittsdatum,

    t1.datum,t1.code,t1.start_moment,t2.stop_moment,t1.groupid

    FROM svtcs T1 JOIN svtcs T2 ON (t1.personalnummer=t2.personalnummer)

    WHERE t1.stop_moment =

    (SELECT MAX(t3.stop_moment)

    FROM svtcs T3

    WHERE (t3.personalnummer=t1.personalnummer)

    AND t3.stop_moment =t2.start_moment)

    this insert is weired

    Do you...

  • RE: top 2 dates

    First is mine ...sec is just a translation of what Remi suggested : ) ( which is like yours)

    the Exec plan for the first is cheaper

  • RE: top 2 dates

    declare @t table([name] varchar(3),[date] datetime)

    insert into @t

    select 'aaa', '8/19/2005' union all

    select 'bbb', '8/19/2005' union all

    select 'ccc', '8/20/2005' union all

    select 'aaa', '7/29/2005' union all

    select 'bbb', '8/24/2005' union...

  • RE: FROM clause - easy syntax question

    comma means a join between result of

     (fooTable foo      

     inner join barTable bar on foo.id = bar.ForeignKey)

    and #tmpDates

  • RE: counting a derived column

    where

    startDate IS NOT NULL and

    endDate IS NOT NULL and

    datediff(yy, startDate, endDate) > @numYears

  • RE: Cursor Versur Temporary Table

    select top 1 *

    from TestRequestState

    WHERE StateId = '11'

    ORDER BY TestRequestNO DESC

  • RE: Cursor Versur Temporary Table

    Just add  NMB of Variable =as many FIELDS you have and do a

     select var1=field1, var2=field2 ...

    just like in this example

    declare @Tmp table (a int,b int identity(1,1))

    insert into

  • RE: Building Tables

    Just put all fields that you have in 1 line and read Normalization to create your tables

  • RE: Debugging stored procedure

    This query selects those groups (folio_no, product_cd) that have ONLY 1 value for rm_cd in GROUP

    count(distinct rm_cd). min(rm_cd) =MIN is used ONLY because they don't GROUP by rm_cd so they...

  • RE: Optimizing Query

    Also try to change the IDLocation data type to be an INT (wich should cover your location) but will MUCH faster than have UniqueIdentifier

    IDLocation='{2D93FD6E-64F7-4A0A-A7F9-0B806D8907ED}'

Viewing 15 posts - 136 through 150 (of 321 total)