Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #1930
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Erland Sommarskog <esquel@sommarskog.se> |
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: WHILE LOOP AS FOR LOOP |
| Date | Wed, 29 Jul 2015 15:44:21 +0000 (UTC) |
| Organization | Erland Sommarskog |
| Lines | 31 |
| Message-ID | <XnsA4E6B4B775C33Yazorman@127.0.0.1> (permalink) |
| References | <d5581480-cb05-4b19-8f82-995f7bfe01e3@googlegroups.com> <XnsA4E6A3D9FCE25Yazorman@127.0.0.1> <6141367c-ecc2-4a6b-aa21-1b006053a8fb@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Wed, 29 Jul 2015 15:44:21 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="5d404a5d864426cbf50ddbcd9433a6e4"; logging-data="23369"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IzfxVAbijBT+LJv8MJ8m5" |
| User-Agent | Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32) |
| Cancel-Lock | sha1:oMpSH6XN2yVnUTHIV77q6mdGH4c= |
| Xref | csiph.com comp.databases.ms-sqlserver:1930 |
Show key headers only | View raw
Jessica González (jess.rgm@gmail.com) writes:
> thanks.. but
>
> SET IDENTITY_INSERT table ON;
> INSERT INTO table(pk,activo,permiso,rol)
> SELECT IDENT_CURRENT('table')+1,'S',id, 1
> FROM table2
>
>
> return error
>
> Violation of PRIMARY KEY constraint 'PK__table__3213E83F2B947552'.
> Cannot insert duplicate key in object 'table'. The duplicate key value
> is (6).
Why do you fiddle with IDENTITY_INSERT ON? That is an option you rarely have
any reason to play with. And IDENT_CURRENT you have even more rare reason to
touch. That is not a particularly useful function.
If you have made the column an IDENTITY column, you should not assign the
values explicitly. And vice versa: if you want to be able to specify the
values explicitly, you sould not use IDENTITY.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
WHILE LOOP AS FOR LOOP Jessica González <jess.rgm@gmail.com> - 2015-07-29 06:58 -0700
Re: WHILE LOOP AS FOR LOOP Erland Sommarskog <esquel@sommarskog.se> - 2015-07-29 14:04 +0000
Re: WHILE LOOP AS FOR LOOP Jessica González <jess.rgm@gmail.com> - 2015-07-29 07:31 -0700
Re: WHILE LOOP AS FOR LOOP Erland Sommarskog <esquel@sommarskog.se> - 2015-07-29 15:44 +0000
Re: WHILE LOOP AS FOR LOOP rja.carnegie@gmail.com - 2015-07-29 10:03 -0700
Re: WHILE LOOP AS FOR LOOP --CELKO-- <jcelko212@earthlink.net> - 2015-08-14 17:54 -0700
csiph-web