Welcome to Sign in | Help
in Search

Alterarea unei coloane IDENTITY

Last post 02-19-2007, 11:39 AM by rar. 3 replies.
Sort Posts: Previous Next
  •  02-19-2007, 10:55 AM 1860

    Alterarea unei coloane IDENTITY

    Vreau ca sa setez identity pe null ca sa pot sa fac un inser intr-un tabel:

    ALTER TABLE tbl_name ALTER COLUMN col_name DROP IDENTITY

    imi afiseaza un mesaj de eroare:

    Incorrect syntax near the keyword 'IDENTITY'. 

    Nu stiu de unde vine eroare ca pe unde am cautat ca asa trebuia asa fie comanda. Folosesc SQL server 2005 Express Edition 

  •  02-19-2007, 11:13 AM 1861 in reply to 1860

    Re: Alterarea unei coloane IDENTITY

    Nu, nu asta e calea de urmat

    uitati-va in Books Online la SET IDENTITY_INSERT- prin ea poti inactiva temporar aceasta proprietate pentru a

    introduce propriile valori in coloana cu IDENTITY 


    Gheorghe Ciubuc,SQL Server Influencer, MCP(SQL 2000), MCTS (SQL Server 2005) , OCA(Oracle 9i), Sybase(Brainbench)
  •  02-19-2007, 11:19 AM 1862 in reply to 1861

    Re: Alterarea unei coloane IDENTITY

    uite un exemplu:

     

    create table t1 (a int identity, b int)

    GO

    insert t1(b)values(3)

    insert t1(b)values(3)

    insert t1(b)values(3)

    insert t1(b)values(3)

    GO

    select * from t1

    --a b

    --1 3

    --2 3

    --3 3

    --4 3

    GO

    set identity_insert t1 on

    insert t1(a,b) values (6,6)

    set identity_insert t1 off

    insert t1(b)values(3)

    GO

    select * from t1

    --1 3

    --2 3

    --3 3

    --4 3

    --6 6

    --7 3


    Cătălin D.
  •  02-19-2007, 11:39 AM 1863 in reply to 1862

    Re: Alterarea unei coloane IDENTITY

    Da aveti dreptate asa merge din prima. M-au indus in eroare unele referinte de pe net. Mii de multumiriBig Smile
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems