SQLServerCentral is issuing a public apology to Itzik Ben-Gan

  • Hi,

    Please be careful do real research,

    http://www.sqlservercentral.com/articles/SQLServerCentral/105392/

    In order to try to win a copy of

    Microsoft SQL Server 2012 HIgh-Performance T-SQL Using Window Functions authored by Mr. Itzik Ben-Gan

    I publish this batch

    I would like to win one copy

    Regrets to all of you,

    CREATE TABLE #Mytable22

    (

    gcounter int not null,

    codesud varchar(10),

    sequence int,

    forms char(1),

    caccount varchar(10),

    account numeric(18,2),

    covarname varchar(10),

    covaryear varchar(10)

    )

    ALTER TABLE [dbo].[#Mytable22] ADD CONSTRAINT [PK_T_PAG2] PRIMARY KEY CLUSTERED

    (

    [gcounter] ASC

    )

    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    CREATE TABLE #Mytable33

    (

    gcounter int not null,

    codesud varchar(5),

    sequence int,

    forms char(1),

    caccount varchar(10),

    account numeric(18,2),

    covarname varchar(2),

    covaryear varchar(4)

    )

    ALTER TABLE [dbo].[#Mytable33] ADD CONSTRAINT [PK_T_PAG3] PRIMARY KEY CLUSTERED

    (

    [gcounter] ASC

    )

    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    Insert into #Mytable33

    (gcounter,codesud,sequence,forms,caccount,account,covarname,covaryear)

    SELECT 76,'05961',cast('1' as int),'A','1200000000',cast('9000000.00' as numeric(18,2)),'03','2011'

    Insert into #Mytable33

    (gcounter,codesud,sequence,forms,caccount,account,covarname,covaryear)

    SELECT 77,'05961',1,'A','1200000000',9000000.00,'03','2011'

    Insert into #Mytable33

    (gcounter,codesud,sequence,forms,caccount,account,covarname,covaryear)

    SELECT 1,'05961',3,'F','5120000000',-246395.83,'03','2011' UNION ALL

    SELECT 2,'03421',32,'F','4319910000',5987405.04,'03','2011' UNION ALL

    SELECT 3,'03621',3,'F','5120000000',-8710527.17,'03','2011' UNION ALL

    SELECT 4,'04721',3,'F','5120000000',-16825100.70,'03','2011' UNION ALL

    SELECT 44,'04721',3,'F','5120000000',-16825100.70,'03','2011' UNION ALL

    SELECT 45,'04721',3,'F','5120000000',-16825100.70,'03','2011' UNION ALL

    SELECT 5,'04722',45,'F','4480910600',928.15,'03','2011' UNION ALL

    SELECT 52,'04722',45,'F','4480910600',928.15,'03','2011' UNION ALL

    SELECT 53,'04722',45,'F','4480910600',928.15,'03','2011' UNION ALL

    SELECT 6,'04723',45,'F','4480910100',66064.50,'03','2011'

    Insert into #Mytable22

    (gcounter,codesud,sequence,forms,caccount,account,covarname,covaryear)

    SELECT 1,'05961',3,'F','5120000000',-246395.83,'03','2011' UNION ALL

    SELECT 2,'03421',32,'F','4319910000',5987405.04,'03','2011' UNION ALL

    SELECT 3,'03621',3,'F','5120000000',-8710527.17,'03','2011' UNION ALL

    SELECT 6,'04723',45,'F','4480910100',66064.50,'03','2011'

    SELECT ROW_NUMBER() OVER (order by b.gcounter) as 'ROWNUMBER',b.codesud as 'ceda2', b.sequence, b.forms

    FROM #Mytable33 AS b

    WHERE (b.gcounter IN (SELECT d.gcounter FROM #Mytable22 AS d))

  • You might need to post in this thread http://www.sqlservercentral.com/Forums/Topic1519856-824-1.aspx, but I'm not sure. 😉

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply