How to pass dynamically integer as column name to a query
-
Hi all, declare @str1 varchar(500) declare @str2 varchar(500) declare @str3 varchar(500) declare @str4 varchar(500) select @str1=ud_id from cm_tb_002 where username='admin'; select @str3=role_id from cm_tb_012 where tb012_id=@str1; select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and [15]='1'; select tb001_id from cm_tb_001 where menu_prnt=@str4; Here i want to pass @str3 to a this query select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and @str3='1'; but the @str3 column is an bigint column. ex. 15 i.e column name In sql sever this value is storing as [15] as column name. Now i want to pass this value to this query select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and @str3='1'; Please help me on this.
i want to join this group
-
Hi all, declare @str1 varchar(500) declare @str2 varchar(500) declare @str3 varchar(500) declare @str4 varchar(500) select @str1=ud_id from cm_tb_002 where username='admin'; select @str3=role_id from cm_tb_012 where tb012_id=@str1; select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and [15]='1'; select tb001_id from cm_tb_001 where menu_prnt=@str4; Here i want to pass @str3 to a this query select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and @str3='1'; but the @str3 column is an bigint column. ex. 15 i.e column name In sql sever this value is storing as [15] as column name. Now i want to pass this value to this query select @str4=tb001_id from cm_tb_001 where menu_activ = 1 and child_lvl = 0 and @str3='1'; Please help me on this.
i want to join this group