I have a table called Users
with these columns
Username - Nvarchar(50).
Password - Nvarchar(50).
Now I have this data
UserName Password
---------- ----------
adimin 123456
test 1234
abc 123
abc 123
Now I'm trying to ( manually ) delete the abc
users and I'm getting this error:
I can add more users and update them and delete them, but I can't do anything with the abc
users.. Why does it happen?
You can delete the records with a delete statement rather than manually in the IDE:
delete from users
where username = 'abc'
Visual Studio is complaining because you didn't define a Primary Key . Add, for example, an identity column and it won't complain any more (since it'll know exactly which row to delete).
Ex.: ALTER TABLE users ADD id INT IDENTITY PRIMARY KEY
If you want to delete all data in a table. you can use following SQL statement
DELETE FROM table_name
ex :- DELETE FROM tblReOrderLevel
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.