Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Using Find and Replace with Regular...
Using Find and Replace with Regular Expressions to match one word and exclude another
Rate Topic
Display Mode
Topic Options
Author
Message
tskelley
tskelley
Posted Wednesday, December 12, 2012 11:36 AM
SSC Rookie
Group: General Forum Members
Last Login: Yesterday @ 6:34 AM
Points: 33,
Visits: 758
I am using Find and Replace in SSMS to search for any line in my T-SQL code that contains a CREATE but does not include a following DBO. (not case-sensitve) to qualify the object being created. I am able to query all occurrences where CREATE and DBO exist, but have not had much luck trying to exclude where DBO did not follow the CREATE somewhere on the line.
For example, this below code finds all CREATE followed by a DBO on the line:
<CREATE(([^:a]+[:a]+)^1|([^:a]+[:a]+)^2|([^:a]+[:a]+)^3)[^:a]+DBO>
I just do not have the Regex mettle to find where a DBO does not trail the CREATE.
Any help would be greatly appreciated, as I am a little stuck on this one.
Thank you,
Tom
Post #1395826
Sean Lange
Sean Lange
Posted Wednesday, December 12, 2012 11:58 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 8:46 AM
Points: 8,547,
Visits: 8,204
like '%create%dbo%'
Not really sure what you are looking for. Also if you only the dbo schema why does it matter much if the object is not fully qualified?
_______________________________________________________________
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
Post #1395831
tskelley
tskelley
Posted Wednesday, December 12, 2012 12:10 PM
SSC Rookie
Group: General Forum Members
Last Login: Yesterday @ 6:34 AM
Points: 33,
Visits: 758
Hello and thanks for the quick reply. I am trying to use the Regular Expressions feature in Find and Replace of the SSMS UI to search my text file that contains our T-SQL code.
Post #1395834
GSquared
GSquared
Posted Wednesday, December 12, 2012 12:23 PM
SSCoach
Group: General Forum Members
Last Login: Monday, May 06, 2013 1:09 PM
Points: 15,439,
Visits: 9,569
I don't think that's a regex issue. Wouldn't you just use a find with a "and not" in it? Find anything with CREATE, and not with the regex you already wrote?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1395839
tskelley
tskelley
Posted Wednesday, December 12, 2012 3:52 PM
SSC Rookie
Group: General Forum Members
Last Login: Yesterday @ 6:34 AM
Points: 33,
Visits: 758
I am using the Find and Replace dialog from within SSMS. I have a large text file (> 100K lines) that includes a delta of all our change scripts.
Post #1395910
Sean Lange
Sean Lange
Posted Thursday, December 13, 2012 7:43 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 8:46 AM
Points: 8,547,
Visits: 8,204
I still say that if you are only looking for dbo that it seems unnecessary. If you have only one schema everything will be created there anyway. Unless you are just trying to figure out how to make the regex work and you can tweak it slightly to check for each schema. I have never had great success with the regex tool in the search dialog. Maybe it is my inability to create complex regex.
_______________________________________________________________
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
Post #1396195
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.