validate if table exists while selecting and inserting SQL Server -
hello have dynamic query like
set @template = 'select x x,... temporaltable from' + @table_name then execute it
exec (@template) - how validate if
temporaltableexists, if so, drop it?
use information schema or sp_help function.
i prefer information schema since it's sql ansi , can port code other databases:
select count(1) information_schema.tables table_name = 'temporaltable'; sys.tables sqlserver specific option similar inforamtion schema can explore.
Comments
Post a Comment