Hi All.
Can you tell me a way to concatinate all the columns in table dynamically and insert into a another table based on the Code and join operator. If there is a join operator then we should have that included in just a row . the resultant table looks like dbo.script
drop table Dbo.Test1
go
create table Dbo.Test1
(
Code varchar(3),
fieldname varchar(32), ,
operator varchar(32),
operand varchar(32),
JoinOperator varchar(32),
OrderOfPrecedence Varchar(32)
)
insert into Dbo.Test1
select 'ad','Name1','not in', '(alex,tom)','AND',1
union
select 'ad','state' ,'=', 'Texas','',2
union
select 'adc','Name1','not in', '(alex1,tom2)','',1
drop table dbo.Script
create table dbo.Script
(
Code varchar(3),
Script varchar(max))
insert into dbo.Script
select 'ad','Name1 not in (''alex'',''tom'') AND state = ''texas'''
union
select 'adc','Name1 in (''rix'',''sam'')'