If you want to delete all rows from student_course and there are no dependencies on that table in the database, the TRUNCATE TABLE student_course should be faster.
which is best truncate or delete to remove all rows from table student_course?
I work on sql server 2017
i need to delete all rows from table student_course
but i don't know use
delete from student_course
or
truncate table student_course
table student_course
studentid pk
courseid pk
table student table
studentid pk
table courses
courseid pk
student_course table have relation with courses table and student table
so which command will be used to delete all rows from table student_course
truncate or delete ?
What I have tried:
delete from student_course
or
truncate table student_course
Developer technologies | Transact-SQL
SQL Server | Other
1 additional answer
Sort by: Most helpful
-
Tom Phillips 17,771 Reputation points
2022-04-27T19:34:39.947+00:00 If you have an foreign key to the table, you must use delete, instead of truncate.