sql server 2008 - Generate sql select statements with data from another table -


issueprop = "text">

Issue: I have a table, it is called all the columns with attributes (table name, column name) among others.

Now, what I want to achieve, is to prepare a selection statement for each record of this table. In the pseudocode: In the (table, column) for

  (select the table name, column name from AllColumns), select the 'Table', the column from the table where ' Can you help with% blah% 'column  

?

You can use the WHILE loop and a temporary table, then you To bring all records into a temporary table and then to select the loop through the record or you want to execute any process, as follows;

  DECLARE @TempTable TABLE (ID INT INTITY 1,1), table Vararar (100), Column Vararar (100)) Insert in the @TempTable SELECT table; Column DECLARE @ LOOP INT DECLARE @COUNT INT SET @LOOP = 0 SET @COUN = 1 SELECT @LOOP = COUNT (1) to @TempTable WHILE @COUNT & lt; = @LOOP BEGIN @TempTable Select the column where the column '% blah%' and id = @COUNT SET @COUNT = @COUNT + 1END  

Comments