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 temporaltable exists, 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

Popular posts from this blog

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -