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

altering all objects to find syntax errors Expand / Collapse
Author
Message
Posted Friday, July 25, 2014 8:30 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 11:07 AM
Points: 53, Visits: 1,123
how to alter all objects in database i want to find if can any syntax errors in my database after restoring from sql 2008 to 2012. i Can create as test and drop them but trying to find a way to alter proc , views and functions
Post #1596241
Posted Friday, July 25, 2014 9:25 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:34 PM
Points: 12,923, Visits: 12,342
mxy (7/25/2014)
how to alter all objects in database i want to find if can any syntax errors in my database after restoring from sql 2008 to 2012. i Can create as test and drop them but trying to find a way to alter proc , views and functions


Are you saying you think you need to recompile every single object in your database because they contain syntax errors? What are you really trying to do?


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1596281
Posted Friday, July 25, 2014 9:35 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:34 PM
Points: 12,895, Visits: 32,093
object definitions like procedures, views and functions can become invalid if the underlying objects they use have been altered or dropped after being created.

I created this script a while ago that i use for checking for invalid objects.

this script finds all Invalid Objects in SQL that no longer compile due to dropped/renamed objects or columns, for example.
there's no way to discover this info without actually trying to recompile, AFAIK.
for Invalid Objects, it's not like oracle, where there is a column to query to test whether something was compiled successfully.
note this doesn't give you a list of what is broken NOW, but rather tries to recompile everything, and reports what fails to compile.

if you have an object that does not follow this convention(single space between create and object type),
you might get an error "There is already an object named 'SP_XXXX' in the database." as an error, which is because the REPLACE did not successfully replace the CREATE with an ALTER
so the script tries to CREATE instead of alter.
convention: CREATE[single space]PROC...CREATE[single space]VIEW...CREATE[single space]FUNCTION

sp_InvalidObjects.txt


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1596285
Posted Friday, July 25, 2014 10:03 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 11:07 AM
Points: 53, Visits: 1,123
trying to find a way tsql code that is not compatible on sql 2012. and also as lowell mentioned when underline objects are modified and dependent objects are not updated properly app might fail when those objects are being used
Post #1596306
Posted Friday, July 25, 2014 10:03 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 11:07 AM
Points: 53, Visits: 1,123
thanks i will try your scripts
Post #1596307
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse