Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inner join

Author  Topic 

sqldoubt
Starting Member

17 Posts

Posted - 2010-07-21 : 13:04:20


select * from step S1
inner join step S2 on S2.Batchid=S1.Batchid and S2.stepid=S1.Stepid
and S2.AttributeName='Destination.Staging' and S2.AttributeValue='1'
inner join importstepattribute S3 on S3.Batchid=S2.Batchid and IA3.stepid=S2.Stepid
and S3.AttributeName='Destination.UserOptions' and S3.AttributeValue='append'

I need to check the table step
Declare @Sql varchar(max)
select @sql='if not exists (select * from stepwhere batchid='+ S1.batchid +'
and stepid='+ S1.stepid +'and attributename='+ 'forcestart'
exec (@sql) print @sql


and then if it doesnt exist i need to insert forcestart for that particular batchid andstepid
how to do this ........



insert into importstepattribute (stepid,batchid,attributename,attributevalue)
values('+Ias1.batchid+','+IA1.stepid+','''forcestart''','''1''')
   

- Advertisement -