Expert Must give me Answer on This..

  • Hi every one...

    i am facing a problem in sql server 2000. i want to find a string REP in my database tables. in my data base there are 1000 tables and i want to find out a list of tables and columns in which this rep string recide........

    for this i made a dynamic query.. but the output is suffecient ....logic of my query is ......

    first i pick all tables from the information_schemas.columns in which column_name like '%CODE%' after that i insert all the informtion into a temp table and apply a loop for each record. after that i made a string query in which i pass the table name and column name and the matching string . all those table which contains the rep field is inserted into another temp table .

    but when i separtly check those table and the column with the matching string REP i got no result . mean i could not find the right table name in which this field recide.....

    i just want to ask to all. Is there any sp's and query  should i use to find a particluar string in my database .. beacuase mannuly table checking is  is time consuming ....

     

    One more question in this post is it true that we cannot use Exec or EXECUTE statment in IF Exists clause..... when i am doing this it give me error .. incorrect syntex )..

    for this question i give you the example.

    Declare @sSql as varchar(500)

    Set @sSql = 'Select null from title(Nolock) where titleid = 12345'

    if exists(EXEC(@sSQl))

    begin

    .........................................

    end

     give your valuable suggestion on this ..........

  • Thanks , this link is really good . and help me  more.

    One more question in this post is it true that we cannot use Exec or EXECUTE statment in IF Exists clause..... when i am doing this it give me error .. incorrect syntex )..

    for this question i give you the example.

    Declare @sSql as varchar(500)

    Set @sSql = 'Select null from title(Nolock) where titleid = 12345'

    if exists(EXEC(@sSQl))

    begin

    .........................................

    end

     give your valuable suggestion on this ..........

  • Can you explain why you need dynamic SQL here?

    _____________
    Code for TallyGenerator

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply