July 25, 2014 at 8:30 am
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
July 25, 2014 at 9:25 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 25, 2014 at 9:35 am
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
Lowell
July 25, 2014 at 10:03 am
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
July 25, 2014 at 10:03 am
thanks i will try your scripts
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply