Enni

Enni

  • NA
  • 30
  • 4.2k

How to pass tablename as parameter in SP to add another col?

Jul 16 2018 8:15 AM
 Hi, Please help me to solve this. 
 
I have three 3 tables with some data and column names are same.
 
June_2018(table name 1)
 
id Name
1 Critical
2 Major
3 Critical
4 Minimum
5 Major
 
 
July_2018
id Name
6 Critical
7 Major
8 Critical
9 Minimum
10 Major
 
August_2018
id Name
11 Critical
12 Major
13 Critical
14 Minimum
15 Major
 
I need a stored procedure where tablename should be passed as the parameter then
Critical, Major should be as Major  as another column and Minimum should be updated as  Minimum. Expected output should be as follows.
 
Exec procedurename(Tablename as parameter) 
 
id Name    Staus
1 Critical    Major
2 Major      Major
3 Critical     Major
4 Minimum    Minimum
5 Major       Major
 
 Thanks in advance.
 
 

Answers (3)