TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sujeet Raman
861
927
354.1k
how to check a table is empty and if it is empty drop table?
Sep 4 2020 2:27 PM
I am trying to check a table is empty and if it is empty drop the table in dynamic sp but my query is not working.2 methods i have tried
I am checking if a coloumn is null or empty will drop the table
set
@dropempty=
'IF EXISTS (SELECT * FROM '
+ @
table
+
' WHERE city IS NULL OR country= '
' '
' ) DROP TABLE '
+ @
table
select
@dropempty
EXEC
sys.sp_executesql @dropempty
2nd methods row check
set
@dropempty=
'IF EXISTS (SELECT 1 FROM '
+ @
table
+
''
') DROP TABLE '
+ @
table
+
''
EXEC
sys.sp_executesql @dropempty
Reply
Answers (
5
)
.NetCore dependency injection and optional params on assembly scanning
How JsonP media type formatter actually works?