Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Update Help.. Expand / Collapse
Author
Message
Posted Wednesday, March 27, 2013 10:47 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 10:13 PM
Points: 206, Visits: 748
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.
Post #1436260
Posted Thursday, March 28, 2013 2:04 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, August 7, 2014 3:30 AM
Points: 2,631, Visits: 4,722
You can use the below mentioned query to find all un-encrypted routines using "TABLEA.ID"

SELECT	OBJECT_NAME(object_id) AS RoutineName
FROM sys.sql_modules AS sm
WHERE sm.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/
Post #1436298
Posted Thursday, March 28, 2013 2:08 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, July 18, 2014 9:09 AM
Points: 870, Visits: 2,385
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
Post #1436300
Posted Thursday, March 28, 2013 8:49 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 4:28 PM
Points: 2,027, Visits: 3,023
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)
"In America, every man is innocent until proven broke!" Brant Parker
Post #1436520
Posted Friday, March 29, 2013 4:21 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 14, 2014 11:01 AM
Points: 11, Visits: 33
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'
Post #1437130
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse