Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


altering all objects to find syntax errors


altering all objects to find syntax errors

Author
Message
mxy
mxy
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 2933
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
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16624 Visits: 17024
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)
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14967 Visits: 38985
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

mxy
mxy
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 2933
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
mxy
mxy
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 2933
thanks i will try your scripts
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search