0

I need to add some columns dynamically in a table (TargetTable). Before doing that I need to check whether the columns are already exists in TargetTable. If they do not exist, then that column will be added, otherwise not.

This is not for fixed column. These columns are storing at SourceTable's rows.

How do I check the existence of each column before adding in the TargetTable?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
LazyLoading
  • 121
  • 4
  • 9
  • Which part are you struggling with - [checking if the column exists](http://stackoverflow.com/q/133031/1048425), or [adding a column dynamically](http://stackoverflow.com/q/2761933/1048425)? – GarethD Jul 08 '15 at 07:54
  • checking if the column exists – LazyLoading Jul 08 '15 at 08:03
  • simple column existence is covered already, and extending that to refer to data in your sourcetable will be join/filter. Use any means (count rows returned, cursor through results) to decide what to add... otherwise your question is incomplete.. – simon coleman Jan 26 '21 at 22:49

0 Answers0