Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

New Code formatting engine rolled out Expand / Collapse
Author
Message
Posted Monday, September 28, 2009 2:50 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Administrators
Last Login: Friday, May 23, 2014 3:06 AM
Points: 7, Visits: 274
We've now updated the syntax highlighting here on the forums. We've also tweaked the IFCodes to try and clarify which should be used for what. The revised list of tags are as follows:

[ code ] - Will default to SQL highlighting
[ code ="sql" ] - SQL highlighting
[ code ="xml" ] - XML highlighting
[ cpde="vb" ] - VB highlighting
[ code ="other" ] - Any other code you'd like highlighted. This option relies on the highlighter to determine the language, so YMMV. As we're using Google Code Prettify, you can find more details on the supported languages here
[ code ="plain" ] - This option just provides a fixed font, for when you don't want syntax highlighting, or the "other" option is not satisfactory.

I've updated the IFCode Shortcuts, so the new Codes should appear in the list when you're composing a post.

Here are some (pretty vanilla) examples from me, using the new Codes:

Using [ code ]:
SELECT *
FROM Customers
WHERE CustomerId = 123456

Using [ code="sql" ]
SELECT *
FROM Customers
WHERE CustomerId = 123456

Using [ code="xml" ]
<xml>
<customer id="123456">
<name>John Doe</name>
</customer>
</xml>

Using [ code="vb" ]
Imports System

Class [class]
Shared Sub [shared](ByVal [boolean] As Boolean)
If [boolean] Then
Console.WriteLine("true")
Else
Console.WriteLine("false")
End If
End Sub
End Class

Module [module]
Sub Main()
[class].[shared](True)

' This prints out: ".
Console.WriteLine("""")

' This prints out: a"b.
Console.WriteLine("a""b")

' This prints out: a.
Console.WriteLine("a"c)

' This prints out: ".
Console.WriteLine(""""c)
End Sub
End Module

Dim d As Date
d = # 8/23/1970 3:45:39AM #
d = # 8/23/1970 #
d = # 3:45:39AM #
d = # 3:45:39 #
d = # 13:45:39 #
d = # 13:45:39PM #

Dim n As Float
n = (0.0, .99F, 1.0E-2D, 1.0E+3D, .5E4, 1E3R, 4D)

Dim i As Integer
i = (0, 123, 45L, &HA0I, &O177S)

Using [ code="other" ]
public class HelloWorld()
{
public static void main(string[] args)
{
Console.Writeline("Hello World!")
}
}

Using [ code="plain" ]
public class HelloWorld()
{
public static void main(string[] args)
{
Console.Writeline("Hello World!")
}
}


I've created this new thread (rather than post in this old one) so we can keep track of any issues/bugs with the new engine. If you run into any problems, please let us know by posting them here!

Thanks!


Ben Adderson
Web Tester
Red Gate Software
Post #794401
Posted Wednesday, September 30, 2009 1:12 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
So [ code="vb" ] has been removed then? Wow, that's a bummer.

I have tried to replace it with [ code="other" ], unfortunately, "other" seems to mean C/C++/C#/Java or anything else that looks like C. It completely messes up the comment's for VB programs (because it treats them like a C/C++/C#/Java quotation mark). ...


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #795972
Posted Wednesday, September 30, 2009 1:20 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 15,444, Visits: 9,596
I like that my tab indents don't go all wonky with the SQL one. Hadn't tried that option before, but noticed it on the bar and tried it a few days ago. Very nice.

- 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 #795977
Posted Wednesday, September 30, 2009 1:23 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
What's really odd is that according to Goggle, this problem (VB comments) was fixed back in January.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #795980
Posted Wednesday, September 30, 2009 7:46 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:16 PM
Points: 37,102, Visits: 31,655
Just testing....

/**********************************************************************************************************************
Purpose:
Returns a single result set similar to sp_Space used for all user tables at once.

Notes:
1. May be used as a view, stored procedure, or table-valued funtion. 2. Must comment out 1 "Schema" in the SELECT list below prior to use. See the adjacent comments for more info.

Revision History:
Rev 00 - 22 Jan 2007 - Jeff Moden
- Initital creation for SQL Server 2000
Rev 01 - 11 Mar 2007 - Jeff Moden
- Add automatic page size determination for future compliance
Rev 02 - 05 Jan 2008 - Jeff Moden
- Change "Owner" to "Schema" in output. Add optional code per Note 2 to find correct schema name
**********************************************************************************************************************/
--===== Ensure that all row counts, etc is up to snuff
-- Obviously, this will not work in a view or UDF and should be removed if in a view or UDF. External code should
-- execute the command below prior to retrieving from the view or UDF.
DBCC UPDATEUSAGE(0) WITH COUNT_ROWS, NO_INFOMSGS

--===== Return the single result set similar to what sp_SpaceUsed returns for a table, but more
SELECT DBName = DB_NAME(),
SchemaName = SCHEMA_NAME(so.UID), --Comment out if for SQL Server 2000
--SchemaName = USER_NAME(so.UID), --Comment out if for SQL Server 2005
TableName = so.Name,
TableID = so.ID/*just a test*/,
MinRowSize = MIN(si.MinLen),
MaxRowSize = MAX(si.XMaxLen),
ReservedKB = SUM(CASE WHEN si.IndID IN (0,1,255) THEN si.Reserved ELSE 0 END) * pkb.PageKB,
DataKB = SUM(CASE WHEN si.IndID IN (0,1 ) THEN si.DPages ELSE 0 END) * pkb.PageKB
+ SUM(CASE WHEN si.IndID IN ( 255) THEN ISNULL(si.Used,0) ELSE 0 END) * pkb.PageKB,
IndexKB = SUM(CASE WHEN si.IndID IN (0,1,255) THEN si.Used ELSE 0 END) * pkb.PageKB
- SUM(CASE WHEN si.IndID IN (0,1 ) THEN si.DPages ELSE 0 END) * pkb.PageKB
- SUM(CASE WHEN si.IndID IN ( 255) THEN ISNULL(si.Used,0) ELSE 0 END) * pkb.PageKB,
UnusedKB = SUM(CASE WHEN si.IndID IN (0,1,255) THEN si.Reserved ELSE 0 END) * pkb.PageKB
- SUM(CASE WHEN si.IndID IN (0,1,255) THEN si.Used ELSE 0 END) * pkb.PageKB,
Rows = SUM(CASE WHEN si.IndID IN (0,1 ) THEN si.Rows ELSE 0 END),
RowModCtr = MIN(si.RowModCtr),
HasTextImage = MAX(CASE WHEN si.IndID IN ( 255) THEN 1 ELSE 0 END),
HasClustered = MAX(CASE WHEN si.IndID IN ( 1 ) THEN 1 ELSE 0 END)
FROM dbo.SysObjects so,
dbo.SysIndexes si,
(--Derived table finds page size in KB according to system type
SELECT Low/1024 AS PageKB --1024 is a binary Kilo-byte
FROM Master.dbo.spt_Values
WHERE Number = 1 --Identifies the primary row for the given type
AND Type = 'E'--Identifies row for system type
) pkb
WHERE si.ID = so.ID
AND si.IndID IN (0, --Table w/o Text or Image Data
1, --Table with clustered index
255) --Table w/ Text or Image Data
AND so.XType = 'U' --User Tables
AND PERMISSIONS(so.ID) <> 0
GROUP BY so.Name,
so.UID,
so.ID,
pkb.PageKB
ORDER BY ReservedKB DESC

SELECT '(1)1)'



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #796105
Posted Wednesday, September 30, 2009 8:39 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:16 PM
Points: 37,102, Visits: 31,655
Ben Adderson (9/28/2009)
We've now updated the syntax highlighting here on the forums. We've also tweaked the IFCodes to try and clarify which should be used for what. The revised list of tags are as follows:


Ben, there are a couple of minor things I need to watch for but I think the change is freakin' awesome! And, it's pretty fast, too! My hat is off to you and anyone else who may have brought this change to pass. No more wrapped lines. No more skipped blank lines. No more having to insert & # 160 ; to keep a blank line. No more posts that are a thousand miles wide. And, not only can I now use IFCode's within an SQL block to help drive a point home for someone, but the end of line markers actually work without first having to paste into WORD or whatever! YEEEEE-HAAAA!!!! You, Sir, have made me a very happy frequent poster. It's been a long time coming and I have to say "Well done!" and thank you, thank you, thank you!


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #796111
Posted Friday, October 2, 2009 1:03 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, July 22, 2013 11:59 AM
Points: 509, Visits: 719
If you wanted to extend it for VB / VB.NET / C# - then you might want to consider ActiPro CodeHighlighter - @ http://www.actiprosoftware.com/Products/DotNet/ASPNET/CodeHighlighter/Default.aspx.

Not sure if it's relevant to you or not, just thought I'd mention it because it's free and the quality of the their products is very high...


Atlantis Interactive - SQL Server Tools
My blog
Why I wrote a sql query analyzer clone
Post #797165
Posted Monday, October 5, 2009 2:08 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Administrators
Last Login: Friday, May 23, 2014 3:06 AM
Points: 7, Visits: 274
RBarryYoung (9/30/2009)
So [ code="vb" ] has been removed then? Wow, that's a bummer.

I have tried to replace it with [ code="other" ], unfortunately, "other" seems to mean C/C++/C#/Java or anything else that looks like C. It completely messes up the comment's for VB programs (because it treats them like a C/C++/C#/Java quotation mark). ...


Hi Barry,

I've just added [ code="vb" ] :)

I've updated my original post with an example, but I'm not very familiar with VB, so if you could give it a try and let us know about any issues, that would be great!


Ben Adderson
Web Tester
Red Gate Software
Post #797704
Posted Monday, October 5, 2009 7:54 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
Ben Adderson (10/5/2009)
RBarryYoung (9/30/2009)
So [ code="vb" ] has been removed then? Wow, that's a bummer.

I have tried to replace it with [ code="other" ], unfortunately, "other" seems to mean C/C++/C#/Java or anything else that looks like C. It completely messes up the comment's for VB programs (because it treats them like a C/C++/C#/Java quotation mark). ...


Hi Barry,

I've just added [ code="vb" ] :)

I've updated my original post with an example, but I'm not very familiar with VB, so if you could give it a try and let us know about any issues, that would be great!

Yup, looks good.

For future reference, here is an example:
'APP_DataBase (vba)
'
' This is the module for the APP application's
'Database functions, routines and constants.
'
'2007-06-08 B.Young Created
'
Option Explicit

Public appDB As New ADODB.Connection


Public Function IsOpenDB() As Boolean
' function to track the DB status
IsOpenDB = (appDB.State <> 0) ' 0=closed
End Function

Public Sub CloseDB()
'Close the database if it is open.
If IsOpenDB Then appDB.Close
End Sub

Public Function OpenDB() As Boolean
'Open the Database and indicate if sucessful
Static sPrev As String
Dim sFile As String

If IsOpenDB Then
OpenDB = True 'we are already open
Exit Function
End If

If sPrev = "" Then sPrev = GetSetting(APP_AppName, "History", "DBName")

With Application.FileDialog(msoFileDialogFilePicker)
'specify the file open dialog
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Access Workbooks", "*.mdb"
.Filters.Add "All Files", "*.*"
.InitialFileName = sPrev
.Title = "Open TIP Database"

.Show

If .SelectedItems.Count > 0 Then
sFile = .SelectedItems(1)
Else 'user canceled ...
OpenDB = False
Exit Function
End If
End With

'appDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\byoung\APP\Main.mdb"
appDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile
On Error Resume Next
appDB.Open
If Err.Number <> 0 Then
MsgBox "Error(" & Err.Number & "): " & Err.Description, vbOKOnly + vbCritical, "Error in OpenDB"
OpenDB = False
Exit Function
End If

'Opened ok, so finsh-up and exit
OpenDB = True
sPrev = sFile
SaveSetting APP_AppName, "History", "DBName", sPrev

End Function

Public Function DBLookup(SQLCommand As String, Optional DefaultVal As Variant = "") As Variant
'Execute a SQL statement and return a single value.
Dim rs As Recordset

On Error GoTo ErrHandler 'Handle any/all DB errors

If Not IsOpenDB Then OpenDB

' execute the command
Set rs = appDB.Execute(SQLCommand)

' extract the first field of the first record returned
rs.MoveFirst
DBLookup = rs.Fields(0).Value
Exit Function

ErrHandler:
' whatever the error is, just assign the default value and return
DBLookup = DefaultVal
Exit Function
End Function

Public Sub DBExecute(SQLCommand As String, Optional RecordsAffected As Long = 0)
'Execute a SQL statement that returns no values.

If Not IsOpenDB Then OpenDB

appDB.Execute SQLCommand, RecordsAffected

End Sub

'===================

Thanks!


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #797897
Posted Thursday, October 8, 2009 12:22 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:55 AM
Points: 43,042, Visits: 36,196
Testing....

Using an inequality character
SELECT session_id FROM sys.dm_exec_requests WHERE session_id &gt; 50

Using escape codes for inequality
SELECT session_id FROM sys.dm_exec_requests WHERE session_id &gt; 50

Using angle brackets to designate a placeholder
USE &lt;Database Name&gt;

Using escape codes to designate a placeholder
USE &lt;Database Name&gt;

Edit: Ok, can someone tell me the secret to posting angle brackets please?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #800256
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse