|
kirkm
Starting Member
1 Post |
Posted - 2011-11-09 : 18:39:00
|
| Hello...Developing something and using (nicely) formatted SQL for the first time, thanks to the online instant SQL formatter.Of the two examples below, if one preferable to the other?Destined for older Excel VBA.1.sql = ""sql = sql & "SELECT Format([Date Entered], ""mmm yyyy"") AS de, " & vbCrLfsql = sql & " Space(4) & artist & String$(10, 9), " & vbCrLfsql = sql & " title & String$(10, 9), " & vbCrLfsql = sql & " [Label] & Space(1) & [Number] & String$(10, 9) AS lc, " & vbCrLfsql = sql & " Cint(ch) & Iif(Val([CH]) = 1, "" week "", "" weeks""), " & vbCrLfsql = sql & " high, " & vbCrLfsql = sql & " Format([Date Left], ""mmm yyyy"") AS dl, " & vbCrLfsql = sql & " tblepcharts.[40], " & vbCrLfsql = sql & " tblepcharts.[40], " & vbCrLfsql = sql & " tblepcharts.[40], " & vbCrLfsql = sql & " tblepcharts.[40], " & vbCrLfsql = sql & " tblepcharts.[40], " & vbCrLfsql = sql & " linenumber, " & vbCrLfsql = sql & " prefix " & vbCrLfsql = sql & "FROM tblepcharts " & vbCrLfsql = sql & "WHERE title LIKE ""%" & iPath & "%"" " & vbCrLfsql = sql & "ORDER BY [Date Entered]"2.sql$ = "SELECT Format([DateEntered], 'mmm yyyy')AS DE, " & _ "Space(4) & tblepdata2.artist & String$(10, 9)," & _ "tblepdata2.title & String$(10, 9)," & _ "tblepdata2.composer & String$(10, 9)," & _ "tblepdata2.[Label] & Space(1) & [Cat] & String$(10, 9) AS LC," & _ "tblep.weekson & Iif(tblep.weekson = 1, ' week ', ' weeks')," & _ "tblep.peak," & _ "Format([DateLeft], 'mmm yyyy') AS dl, " & _ "tblep.blank, " & _ "tblep.blank, " & _ "tblep.blank, " & _ "tblep.blank, " & _ "linenumber, " & _ "[tblEPData2].[Prefix] & [tblEPData2].[SubLetter] AS prefix, " & _ "tblepdata2.cat AS [Number] " & _"FROM tblep " & _ "INNER JOIN tblepdata2 " & _ "ON tblep.prefix = tblepdata2.prefix " & _"WHERE tblepdata2.artist LIKE '%" & _ fred & _"%' ORDER BY tblepdata2.orderbynum;"sql = Replace(sql, "'", Chr(34))Hmmm, the editor here has mucked it up a bit... not so clear now. But using the underscore, or not, and the sets of double quotes... or are both methods pretty much as good as each other ?Thanks, Kirk |
|