September 28, 2009 at 2:50 am
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 AddersonWeb TesterRed Gate Software
September 30, 2009 at 1:12 pm
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). ... 🙁
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
September 30, 2009 at 1:20 pm
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
September 30, 2009 at 1:23 pm
What's really odd is that according to Goggle, this problem (VB comments) was fixed back in January.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
September 30, 2009 at 7:46 pm
Just testing....
/**********************************************************************************************************************
[font="Arial Black"]Purpose:[/font]
Returns a single result set similar to sp_Space used for all user tables at once.
[highlight="RED"]Notes:[/highlight]
[highlight]1. May be used as a view, stored procedure, or table-valued funtion.[/highlight] 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
Change is inevitable... Change for the better is not.
September 30, 2009 at 8:39 pm
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 [font="Arial Black"]very [/font]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
Change is inevitable... Change for the better is not.
October 2, 2009 at 1:03 pm
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[/url]
Why I wrote a sql query analyzer clone
October 5, 2009 at 2:08 am
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 AddersonWeb TesterRed Gate Software
October 5, 2009 at 7:54 am
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!
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
October 8, 2009 at 12:22 pm
Testing....
Using an inequality character
SELECT session_id FROM sys.dm_exec_requests WHERE session_id > 50
Using escape codes for inequality
SELECT session_id FROM sys.dm_exec_requests WHERE session_id > 50
Using angle brackets to designate a placeholder
USE <Database Name>
Using escape codes to designate a placeholder
USE <Database Name>
Edit: Ok, can someone tell me the secret to posting angle brackets please?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 8, 2009 at 1:04 pm
GilaMonster (10/8/2009)
Testing....Using an inequality character
SELECT session_id FROM sys.dm_exec_requests WHERE session_id > 50
Using escape codes for inequality
SELECT session_id FROM sys.dm_exec_requests WHERE session_id > 50
Using angle brackets to designate a placeholder
USE <Database Name>
Using escape codes to designate a placeholder
USE <Database Name>
Edit: Ok, can someone tell me the secret to posting angle brackets please?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2009 at 1:06 pm
Testing Gails Problem...
SELECT 1 WHERE A > B
SELECT 1 WHERE A > B
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2009 at 1:07 pm
Ah... got it. If you type the code in between the code markers, you get the & gt ; character representation. If you paste between the code markers from SSMS, it works just fine.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2009 at 1:08 pm
That doesn't really help me. I've got a fair few 'templates' that I have set up for quick insert via a firefox plugin. Cutting them to management studio and pasting back's time consuming.
Ben, can you maybe look into the < and > please. Should be able to type them in in code blocks.
More testing... Created one of my clippings by copying from SSMS...
DBCC CHECKDB (<Database Name>) WITH NO_INFOMSGS, ALL_ERRORMSGS
directly pasted
DBCC CHECKDB (<Database Name>) WITH NO_INFOMSGS, ALL_ERRORMSGS
Forums don't like me evidentially....
Once more with feeling. Written in management studio, copy, paste
SELECT Something FROM SomeWhere WHERE Col1 <> Col2
🙁
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 8, 2009 at 1:23 pm
SELECT <column list>; FROM <your table here>
SELECT <column>
Like this?
Edit: interesting, worked on preview - then gets modified as above.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 15 posts - 1 through 15 (of 36 total)
You must be logged in to reply to this topic. Login to reply