Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ashley.sql
Constraint Violating Yak Guru
299 Posts |
Posted - 2007-08-16 : 13:32:25
|
Maybe no one thought of this before or they did.I am just playing with thisI create a table with one column only and that column is identity type.create table test(C1 int identity(1,10))now i want to do inserts in this and i want the inserts to be automated not by setting identity insert ONinsert into test values () and everytime i run my insert the data should be added to this table.is this possible. I know its not required but IDEAL MIND IS DEVILS WORKSHOP and this is what i was thinking about during my lunch time.  Ashley Rhodes |
|
|
ashley.sql
Constraint Violating Yak Guru
299 Posts |
Posted - 2007-08-16 : 15:06:13
|
| No body replying to this.need to insert data without setting identity_insert to ONAshley Rhodes |
 |
|
|
ashley.sql
Constraint Violating Yak Guru
299 Posts |
Posted - 2007-08-16 : 15:51:28
|
| Wow No Replies. Is it that dumb?Ashley Rhodes |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
ashley.sql
Constraint Violating Yak Guru
299 Posts |
Posted - 2007-08-16 : 15:59:22
|
| nothing much just curious.Ashley Rhodes |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-08-16 : 16:10:18
|
| >>> now i want to do inserts in this and i want the inserts to be automated not by setting identity insert ONSo, You cannot insert into the identity column >>>insert into test values () and everytime i run my insert the data should be added to this table.What data will you insert and into which column?Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-08-16 : 16:10:33
|
you can do thisCREATE TABLE myTable99(Col1 int IDENTITY(1,1), Col2 char(1))GOSET NOCOUNT ONDECLARE @x intSET @x = 0WHILE @x < 100 BEGIN INSERT INTO myTable99(Col2) SELECT 'a' SELECT @x = @x + 1 ENDSELECT * FROM myTable99GOSET NOCOUNT OFFDROP TABLE myTable99GO Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-08-16 : 18:58:17
|
| [code]CREATE TABLE MyTemp (ID INT IDENTITY(1,1))SET IDENTITY_INSERT MyTemp ONINSERT MyTemp (ID) VALUES(1)SET IDENTITY_INSERT MyTemp OFFSELECT * FROM MyTempDROP TABLE MyTemp[/code] |
 |
|
|
|
|
|