Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
R

Roberto Mazzone

@Roberto Mazzone
About
Posts
9
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • The bookmark star disappear
    R Roberto Mazzone

    In the CodePrject article page the bookmark icon disappear. I can't find more. Am I wrong?

    Site Bugs / Suggestions question

  • When WPF manipulation is ON, ListBox SelectionChanged event isn't fired
    R Roberto Mazzone

    I add manipulation (ManipulationStarting, ManipulationDelta events) to a WPF application. In the main window there is a ListBox for which, before adding manipulation, "tap" events were promoted to mouse events, while now that the Manipulation processor capture the touch device they are no longer promoted. This behavior is well explained by JoshB in this article http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html[^] My question is: how can I get the ListBox selected item when the user "tap" upon a ListBoxItem? Have I to use Surface 2.0 SDK controls (SurfaceListBox)?

    WPF question csharp html wpf

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    David, see my reply to Mike...

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    Mike, I have to preserve the referential integrity of this constraint.

    alter table tA
    add constraint tB_tA_FK1 foreign key (b_id)
    references tB (b_id)

    Situation before moving data from DB_SRC to DB_DST on DB_SRC.tA a_id b_id 1 100 on DB_SRC.tB b_id 100 on DB_DST.tA a_id b_id 1 200 on DB_DST.tB b_id 200 when i insert data from DB_SRC.tB to DB_DST.tB. b_id became 201 and when i insert data from DB_SRC.tA to DB_DST.tA DB_DST.tA.b_id have to became 201. To achieve this goal i used the IDENT_CURRENT for DB_DST.tB (200) plus ROW_NUMBER (the rank progressive, from 1 to n) as previously reported. I solved adding an extracolumn DB_DST.tB.id_src, than on DB_DST.tB b_id id_src 200 201 100 in this way i have the right correspondence to do the work as explained in the previous post. Anyway many thanks for your interest.

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    Mike, anyway i'm an sql script beginner. I know that about IDENT_CURRENT Microsoft report "Be cautious about using IDENT_CURRENT to predict the next generated identity value. The actual generated value may be different from IDENT_CURRENT plus IDENTITY_INCR because of insertions performed by other sessions." The job I have to do is to move rows from DB_SRC to DB_DST having the same schema. DB_DST can be empty or not. ---------------------------- TAB. tA ---------------------------- a_id int identity not null, b_id int not null ----------------------------

    alter table tA
    add constraint tB_tA_FK1 foreign key (b_id)
    references tB (b_id)

    ---------------------------- TAB. tB ---------------------------- b_id int identity not null ---------------------------- this was my first implementation...

    USE [DB_SRC]

    CREATE TABLE #corr_id
    (
    b_id_src INT NULL,
    b_id_dst INT NULL
    }

    DECLARE @IdNext AS INT
    SET @IdNext = IDENT_CURRENT('[DB_DST].dbo.tB')

    -- Set the correspondence
    INSERT INTO #corr_id (b_id_src, b_id_dst)
    SELECT b_id, ROW_NUMBER() OVER (order by b_id) + @IdNext
    FROM tB WHERE b_id IN .....code depending on user choise

    -- Use the correspondence
    INSERT INTO [DB_DST].dbo.tA
    SELECT #corr_id.b_id_src FROM tA INNER JOIN #corr_id ON tA.b_id = #corr_id.b_id_src

    but the IDENT_CURRENT bug (explained in previous post) occured and than...

    USE [DB_DST]
    ALTER TABLE tB ADD id_src INT NULL
    GO

    USE [DB_SRC]

    -- Set the correspondence
    INSERT INTO [DB_DST].dbo.tB (id_src)
    SELECT b_id FROM tB WHERE b_id IN .....code depending on user choise

    -- Use the correspondence
    INSERT INTO [DB_DST].dbo.tA
    SELECT tBDST.b_id FROM tA INNER JOIN [DB_DST].dbo.tB AS tBDST
    ON tA.b_id = tBDST.id_src

    USE [DB_DST]
    ALTER TABLE tB DROP COLUMN id_src
    GO

    BTW, turning back to the post object, is there a built-in function or sp to know if a table was never populated?

    modified on Wednesday, August 5, 2009 8:36 AM

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    First of all many thanks to David Skelly and David Mujica for the work-around about the IDENT_CURRENT bug. Second, i'm an sql script beginner. I know that about IDENT_CURRENT Microsoft report "Be cautious about using IDENT_CURRENT to predict the next generated identity value. The actual generated value may be different from IDENT_CURRENT plus IDENTITY_INCR because of insertions performed by other sessions." The job I have to do is to move rows from DB_SRC to DB_DST having the same schema. DB_DST can be empty or not. --------------------------- TAB. tA --------------------------- a_id int identity not null, b_id int not null ---------------------------

    alter table tA
    add constraint tB_tA_FK1 foreign key (b_id)
    references tB (b_id)

    --------------------------- TAB. tB --------------------------- b_id int identity not null --------------------------- this was my first implementation...

    USE [DB_SRC]

    CREATE TABLE #corr_id
    (
    b_id_src INT NULL,
    b_id_dst INT NULL
    }

    DECLARE @IdNext AS INT
    SET @IdNext = IDENT_CURRENT('[DB_DST].dbo.tB')

    -- Set the correspondence
    INSERT INTO #corr_id (b_id_src, b_id_dst)
    SELECT b_id, ROW_NUMBER() OVER (order by b_id) + @IdNext
    FROM tB WHERE b_id IN .....code depending on user choise

    -- Use the correspondence
    INSERT INTO [DB_DST].dbo.tA
    SELECT #corr_id.b_id_src FROM tA INNER JOIN #corr_id ON tA.b_id = #corr_id.b_id_src

    but the IDENT_CURRENT bug (explained in previous post) occured and than...

    USE [DB_DST]
    ALTER TABLE tB ADD id_src INT NULL
    GO

    USE [DB_SRC]

    -- Set the correspondence
    INSERT INTO [DB_DST].dbo.tB (id_src)
    SELECT b_id FROM tB WHERE b_id IN .....code depending on user choise

    -- Use the correspondence
    INSERT INTO [DB_DST].dbo.tA
    SELECT tBDST.b_id FROM tA INNER JOIN [DB_DST].dbo.tB AS tBDST
    ON tA.b_id = tBDST.id_src

    USE [DB_DST]
    ALTER TABLE tB DROP COLUMN id_src
    GO

    BTW, turning back to the post object, is there a built-in function or sp to know if a table was never populated?

    modified on Wednesday, August 5, 2009 8:26 AM

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    Thanks for replay leckey. I try to explain better. I want to predict what will be the next identity value for a table. If a table has 1 row inserted and deleted, the table is empty and populated. I this case IDENT_CURRENT return 1 and the next id value will be 2. Correct. If a table is empty and never populated IDENT_CURRENT return 1 again (it's a bug) and the next id value will be 1. In this particular circumstance i can't predict the next id value and i would like to know a way to check if a table was populated to achieve my goal. With your code I can't predict the next identity (autonumber) value in the scenario above explained. Anyway, thanks again.

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    Ok, I try to explain better. I want to predict what will be the next identity value for a table. If a table have 1 row inserted and deleted, the table is empty and populated. I this case IDENT_CURRENT return 1 and the next id value will be 2. Correct. If a table is empty and never populated IDENT_CURRENT return 1 again (it's a bug) and the next id value will be 1. In this particular circumstance i can't predict the next id value and i would like to kown a way to check if a table was populated or not. "Select count(*)" don't solve the problem. Anyway many thanks!

    Database database sql-server com sysadmin algorithms

  • How to check for a never populated table on sql server 2005
    R Roberto Mazzone

    I use IDENT_CURRENT to predict the next identity on a table (I know I have to be careful). IDENT_CURRENT return the SEED value (1) for a never populated table (it's a bug...https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=297781[^]) and the same value for an empty table with 1 rows inserted and deleted. so when IDENT_CURRENT return 1 I don't know if the new identity value will be 1 or 2. I have to exec:

    DBCC CHECKIDENT ('table_name', RESEED, 1) --if a table was empty and never populated

    DBCC CHECKIDENT ('table_name', RESEED, 0) --if a table was empty and just populated

    in this way IDENT_CURRENT will return always 1. I'm searching for a more elegant solution than, for an empty table, insert a dummy row, get the IDENT_CURRENT and delete the dummy row! Many thanks to all

    Database database sql-server com sysadmin algorithms
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups