I am using mssql database. Please help me to execute the sql queries based on output of another sql query as follows.
I have one query like 'select productcode from test' . It lists all the product codes.
Based on above query output, If any one of productcode value from above query is "aaaa" then execute sql query1 otherwise execute sql query2.
If 'aaaa' is somewhere embedded in the productcode, use
WHERE productcode like '%aaaa%'
You can use the second form even if the product code starts with 'aaaa', but the first form is likely to be more efficient if you can be certain that you want the productcodes that start with 'aaaa' rather than embedded somewhere in the productcode.