Geeks With Blogs

@woodbasen
  • woodbasen Man må bare elske Fars dag! ungerne laver morgenmad. En gave der garanterer en perfekt @COPENHELL. En halv arbejdsdag og en fodboldkamp :-D about 541 days ago

Woodbase Umbraco - CSS - jQuery - .Net - C#

I had to rename in a column in my database - let's call it Customer.CellPhone. Now 'CellPhone' needs to be 'Mobile'. Not to hard using the build-in SP:

use WebShop
EXEC sp_rename 'Customer.CellPhone', 'Mobile'
go

But what if I used 'CellPhone' in a SP? Then it would fail now... But that's when I found this solution.

create proc spFindWordsInSP
@word nvarchar(100)
as
BEGIN

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%'+@word+'%'
AND ROUTINE_TYPE='PROCEDURE'
ORDER BY ROUTINE_NAME ASC
END

Calling EXEC spFindWordsInSP 'CellPhone' returns all the procedures, where the word You search for is located!

Follow this link to the original article by dotnetfish: http://www.codegain.com/tips/sqlservers/databaseadmin/how-to-find-column-name-within-stored-procedures-in-sql-server.aspx

 

Posted on Tuesday, August 21, 2012 8:27 AM SQL | Back to top


Comments on this post: Renaming columns - and location them in stored procedures

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © woodbase | Powered by: GeeksWithBlogs.net | Join free