error with reftab_hive

05/11/2013 12:00 thoubi96#1
Msg 8101, Level 16, State 1, Line 61
An explicit value for the identity column in table 'Tab_RefHive' can only be specified when a column list is used and IDENTITY_INSERT is ON.



what should i do i dont rly understand actually what is wrong :(
05/11/2013 12:40 Schickl#2
The ID column is an identity column.
This means that the value is generated by the server
Just don't include that column when inserting, or if you really need to specify the ID do what the error suggests you: set IDENTITY_INSERT to ON
Look there for more info: [Only registered and activated users can see links. Click Here To Register...]
05/11/2013 12:53 IceAmStiel#3
Aight people.. take advantage of the identity columns, I know it might be annoying sometimes to insert data in tables with lots of columns but you can make it much more simple..

Code:
Declare	@String nvarchar(1024);
SELECT	@String = ISNULL(@String, N'') + name + N', ' FROM sys.columns WHERE object_id = OBJECT_ID(N'Tab_RefHive') AND is_identity = 0;

SELECT	N'INSERT INTO Tab_RefHive (' + LEFT(@String, LEN(@String) - 1) + N') VALUES (..)';
Output:

[Only registered and activated users can see links. Click Here To Register...]
05/11/2013 14:44 thoubi96#4
Quote:
Originally Posted by IceAmStiel View Post
Aight people.. take advantage of the identity columns, I know it might be annoying sometimes to insert data in tables with lots of columns but you can make it much more simple..

Code:
Declare	@String nvarchar(1024);
SELECT	@String = ISNULL(@String, N'') + name + N', ' FROM sys.columns WHERE object_id = OBJECT_ID(N'Tab_RefHive') AND is_identity = 0;

SELECT	N'INSERT INTO Tab_RefHive (' + LEFT(@String, LEN(@String) - 1) + N') VALUES (..)';
Output:

[Only registered and activated users can see links. Click Here To Register...]


so that query makes it work?

`do i run this for shard or for that table?
05/11/2013 19:00 IceAmStiel#5
Assuming you want to insert data into Tab_RefHive, simply exclude the identity column from the column list in the insert statement.
My query prepares the string for insertions into a table that has an identity column (replace the ".." with your intput parameters).