January 13, 2011 at 12:04 am
Hi,
Is there any way to change all keywords of sp into upper case at once in sql server 2008
January 13, 2011 at 2:40 am
Hi,
There are a number of apps that will automatically reformat SQL. A quick Google search should bring up plenty. I don't use one, so can't recommend one.
If you wanted to do it in the db, here's one way:
search for "Reserved Keywords (Transact-SQL)" in BOL.
Take the list of keywords and populate to a table.
Extract the text for your stored procedure using the following query:
-- get the stored procedure text
declare @text varchar(max)
; with cte as (
select sob.name as ProcName
, mdu.Definition as ProcCode
from sys.objects sob
join sys.sql_modules mdu
on sob.object_id = mdu.object_id
)
select @text = ProcCode
from cte
where ProcName = 'my_Stored_Procedure'
Loop through your table of words to do a replace on the text. Be careful - think about how you might get matches to reserved words in the middle of strings, e.g. IN matches to Initials, FOR matches to Information.
Execute your text variable via sp_executesql.
Regards, Iain
January 13, 2011 at 3:13 am
irobertson has a valid point, there are enough (free) code formatters on the web. Personally, I wouldn't go through the hassle of creating all that code irobertson has written just to put some words in uppercase.
I don't know if you know this shortcut: ctrl+shift+u places a selection in upper case.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 13, 2011 at 7:54 am
My personal preference for this, Red Gate's SQL Prompt Pro. Fantastic tool. Does a heck of a lot more than just format the code too.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 13, 2011 at 7:58 am
kuppurajm (1/13/2011)
Hi,Is there any way to change all keywords of sp into upper case at once in sql server 2008
SSMS Tools : Free : Does a reasonable effort for a free tool - lots of other reasons to have it - not least the query history.
Devart's SQL Complete : Free : Also re-formats the SQL to your preference of indentations, line feeds etc. : bit buggy but new and they respond quickly to bug reports.
Trainee : Cheap : Also fetches coffee and bacon sandwiches...:-D
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
January 13, 2011 at 11:25 am
Grant Fritchey (1/13/2011)
My personal preference for this, Red Gate's SQL Prompt Pro. Fantastic tool. Does a heck of a lot more than just format the code too.
Same recommendation I was going to make.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 13, 2011 at 11:54 am
CirquedeSQLeil (1/13/2011)
Grant Fritchey (1/13/2011)
My personal preference for this, Red Gate's SQL Prompt Pro. Fantastic tool. Does a heck of a lot more than just format the code too.Same recommendation I was going to make.
Do you have the new version that rolls in SQL Refactor functionality? Makes it even better.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 14, 2011 at 12:14 am
Grant Fritchey (1/13/2011)
Does a heck of a lot more than just format the code too.
That sounds like: it does also your dishes, the laundry and it unclogs your toilet 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply