Page 1 of 1

prefixing object name with scheme.

Posted: Wed Apr 15, 2009 11:13 pm
by ravilobo
I need to prefix the objects with schema name. I have the following code,

Code: Select all

CREATE PROC F1
CREATE PROC DBO.F2
I need a RegEx which prefixes "dbo." to objects; at the same time it also takes care of existing schema.

Code: Select all

CREATE PROC DBO.F1
CREATE PROC DBO.F2

Posted: Thu Apr 16, 2009 6:41 am
by ben_josephs
Find what: CREATE PROC ([a-z0-9]+)$
Replace with: CREATE PROC DBO.\1

[X] Regular expression

Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax

Posted: Thu Apr 16, 2009 11:55 am
by ravilobo
Thank you Ben! It worked.

Posted: Thu Apr 16, 2009 12:06 pm
by ravilobo
My apologies for not giving a proper example. The RegEx works for my earlier example, however it is not working for following case,

Code: Select all

CREATE PROC F1 AS SELECT GETDATE()
CREATE PROC DBO.F2 AS select col1 from tab

Posted: Thu Apr 16, 2009 1:22 pm
by ben_josephs
Find what: CREATE PROC ([a-z0-9]+( |$))
Replace with: CREATE PROC DBO.\1

Posted: Thu Apr 16, 2009 1:49 pm
by ravilobo
Amazing! Thank you ben!