Update Help..

  • Hi Guys,

    Need favor.

    Here is the e.g. I am using TABLEA.ID (as an e.g) in my SP.I am not sure how many SP I am using TABLEA.ID. What i want to update TABLEA.ID TO TABLEB.ID from ALL SPs in my database.

    Please let me know if my question is not clear. Any help would be great help.

    Thank You.

  • You can use the below mentioned query to find all un-encrypted routines using "TABLEA.ID"

    SELECTOBJECT_NAME(object_id) AS RoutineName

    FROMsys.sql_modules AS sm

    WHEREsm.definition LIKE '%TABLEA.ID%'

    You can then manually changes all the SP's

    I would suggest you to do some documentation of the procedures involved and make the changes carefully even if it takes a lot of time.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Unfortunately there is no magic wand to do this, so its a pain staking trawl through all SP's, as people may have used Aliases, etc.

    You might be able to get an Idea of the scale by using the

    Select * from sys.syscomments

    WHERE [TEXT] Like '%TABLEA.ID%'

    But for long SP's you may need to link these together using the Id and colId references.

    Select distinct

    SCHEMA_NAME(schema_id) AS [Schema_name]

    , Objects.name Object_Name

    from sys.syscomments

    INNER JOIN sys.objects on objects.object_id=syscomments.id

    You could reverse engineer the database into an SQL server Project if you have VS2008 GDR or VS2010 Premium (I think).

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • Also, be sure to check: sys.sql_expression_dependencies.

    And not just in its own db but in other dbs, esp. on the same instance.

    And the usual disclaimer: even that isn't guaranteed to be every reference, of course. But it's probably the best list of references to that column you can get.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • SELECT obj.Name SPName, sc.TEXT SPText

    FROM sys.syscomments sc

    INNER JOIN sys.objects obj ON sc.Id = obj.OBJECT_ID

    WHERE sc.TEXT LIKE '%' + 'Name Your Column Here' + '%'

    AND TYPE = 'P'

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

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