Forum Discussion
Altering sql object definitions
Hi, I have a few objects, such as stored procedures, views, and inline table valued functions, that I'd like to modify. Currently they contain select references to sales.orderstest table, and I'd like to change the text to Sales.Orders. I'd like to do this with either tsql or powershell. In other words, for functions for instance, I'd like a script (tsql or powershell), to get a list of all functions in the specified database (use a parameter to get the database info), extract the object definition, and where it findes 'Sales.Orderstest' references, it replaces with 'Sales.Orders'
I’d rather do this with one script rather than opening each function independently and modifying them manually.
Any hints, or pointers would be most appreciated.
1 Reply
- olafhelperBronze Contributor
I prefer SQL Server Data Tools - SQL Server Data Tools (SSDT) | Microsoft Learn with a database project for refactoring SQL code, see Rename and Refactoring to Make Changes to your Database Objects - SQL Server Data Tools (SSDT) | Microsoft Learn