NewEra13 Posted October 24, 2014 Share Posted October 24, 2014 Hello, I need to fake data in our development table by creating new row with a new EntityID = 100 but that could have all other data as the same as for EntityID = 99 for example. Msg 2627, Level 14, State 1, Line 2 Violation of PRIMARY KEY constraint 'XPK_FactTable'. Cannot insert duplicate key in object 'DataBase.FactTable'. The statement has been terminated. Thanks ! Link to comment Share on other sites More sharing options...
niche Posted October 24, 2014 Share Posted October 24, 2014 (edited) http://stackoverflow.com/questions/5907206/mysql-insert-into-tbl-select-from-another-table-and-some-default-values Edited October 24, 2014 by niche Link to comment Share on other sites More sharing options...
NewEra13 Posted October 24, 2014 Author Share Posted October 24, 2014 Thanks. By the way, there a ways to know what's the next IDColumn value available in a table ? I mean i want to know what IDColumn valye i can enter when creating my new row that is not already present in my big table. Link to comment Share on other sites More sharing options...
niche Posted October 24, 2014 Share Posted October 24, 2014 (edited) Sounds like you're asking about the keyword WHERE http://www.w3schools.com/sql/sql_where.asp Edited October 24, 2014 by niche Link to comment Share on other sites More sharing options...
NewEra13 Posted October 24, 2014 Author Share Posted October 24, 2014 Actually i found it: SELECT TOP 1 ColumnID FROM DB.FactTableName ORDER BY ColumnID DESC; Thanks for the fast replys. Link to comment Share on other sites More sharing options...
niche Posted October 24, 2014 Share Posted October 24, 2014 You're welcome Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now