sankeerth m

sankeerth m

  • NA
  • 484
  • 23.9k

SqlInsert Query I am unable to restirct Duplicate entries

May 16 2020 12:20 AM
"INSERT INTO kpicolor(KPIName, MinVal, MaxVal, ColorVal, Markersize, UserSession) " +
"SELECT * FROM(SELECT @KPIName, @MinVal, @MaxVal, @ColorVal, @Markersize, @UserSession) AS tmp WHERE NOT EXISTS " +
"(Select KPIName from kpicolor where @MinVal between MinVal And MaxVal And KPIName = @KPIName AND UserSession='" + userSession + "'); ";
 
 if i am adding 1 to 50 it is restricting between numbers. if i add 51 to 100 it is appending the row. after that i am inserting 101 to above numbers it unable to insert. but if add from 52 to 150 it adding again. please help me out this sql query
 

Answers (2)