<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Hello SQL</title>
        <link>http://weblogs.sqlteam.com/jamesw/Default.aspx</link>
        <description />
        <language>en-US</language>
        <copyright>James Wang</copyright>
        <generator>Subtext Version 2.5.1.0</generator>
        <image>
            <title>Hello SQL</title>
            <url>http://weblogs.sqlteam.com/images/RSS2Image.gif</url>
            <link>http://weblogs.sqlteam.com/jamesw/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>A list of SQL best practices</title>
            <link>http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best-practices.aspx</link>
            <description>&lt;p&gt;Here are some SQL programming guidelines and best practices we collected, keeping quality, performance and maintainability in mind. This list is not complete at this moment, and will be constantly updated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
Do not use SELECT * in your queries.
&lt;/li&gt;
&lt;li&gt;
Always use table aliases when your SQL statement involves more than one source.
&lt;/li&gt;
&lt;li&gt;
Use the more readable ANSI-Standard Join clauses instead of the old style joins.
&lt;/li&gt;
&lt;li&gt;
Do not use column numbers in the ORDER BY clause.
&lt;/li&gt;
&lt;li&gt;
Always use a column list in your INSERT statements.
&lt;/li&gt;
&lt;li&gt;
Don’t ever use double quotes in your T-SQL code.
&lt;/li&gt;
&lt;li&gt;
Do not prefix your stored procedure names with “sp_”.
&lt;/li&gt;
&lt;li&gt;
Always use a SQL formatter to format your sql like &lt;a href="http://www.dpriver.com/pp/sqlformat.htm"&gt;Instant SQL Formatter&lt;/a&gt;(Free and Online)
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
Do not use SELECT * in your queries, write out the full syntax.
&lt;/h3&gt;
Always write the required column names after the SELECT statement, like:		

&lt;pre&gt;
SELECT CustomerID, CustomerFirstName, City from Emp;
&lt;/pre&gt;
		
This technique results in reduced disk I/O and better performance.

&lt;h3&gt;
 Always use table aliases when your SQL statement involves more than one source
&lt;/h3&gt;
If more than one table is involved in a from clause, each column name must be qualified using either the complete table name or an alias. The alias is preferred.	
It is more human readable to use aliases instead of writing columns with no table information.

&lt;h3&gt;
Use the more readable ANSI-Standard Join clauses instead of the old style joins
&lt;/h3&gt;
With ANSI joins, the WHERE clause is used only for filtering data. 
Where as with older style joins, the WHERE clause handles both the join condition and filtering data. 

Furthermore ANSI join syntax supports the full outer join.

The first of the following two queries shows the old style join, 
while the second one shows the new ANSI join syntax:

&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;span style="color: green; font-style: italic; "&gt;-- old style join&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;SELECT&lt;/span&gt; &lt;span style="color: maroon; "&gt;a&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt;&lt;span style="color: silver; "&gt;,&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;FROM&lt;/span&gt;   &lt;span style="color: maroon; "&gt;TITLES&lt;/span&gt; &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;,&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: maroon; "&gt;AUTHORS&lt;/span&gt; &lt;span style="color: maroon; "&gt;a&lt;/span&gt;&lt;span style="color: silver; "&gt;,&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: maroon; "&gt;TITLEAUTHOR&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;WHERE&lt;/span&gt;  &lt;span style="color: maroon; "&gt;a&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt; &lt;span style="color: silver; "&gt;=&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: blue; "&gt;AND&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title_id&lt;/span&gt; &lt;span style="color: silver; "&gt;=&lt;/span&gt; &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title_id&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: blue; "&gt;AND&lt;/span&gt; &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title&lt;/span&gt; &lt;span style="color: blue; "&gt;LIKE&lt;/span&gt; &lt;span style="color: maroon; "&gt;‘&lt;/span&gt;&lt;span style="color: silver; "&gt;%&lt;/span&gt;&lt;span style="color: maroon; "&gt;Computer&lt;/span&gt;&lt;span style="color: silver; "&gt;%&lt;/span&gt;&lt;span style="color: maroon; "&gt;’&lt;/span&gt; 
&lt;/span&gt;&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;span style="color: green; font-style: italic; "&gt;--ANSI join syntax&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;SELECT&lt;/span&gt; &lt;span style="color: maroon; "&gt;a&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt;&lt;span style="color: silver; "&gt;,&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;FROM&lt;/span&gt;   &lt;span style="color: maroon; "&gt;AUTHORS&lt;/span&gt; &lt;span style="color: maroon; "&gt;a&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: blue; "&gt;INNER&lt;/span&gt; &lt;span style="color: blue; "&gt;JOIN&lt;/span&gt; &lt;span style="color: maroon; "&gt;TITLEAUTHOR&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;
&lt;br /&gt;         &lt;span style="color: blue; "&gt;ON&lt;/span&gt; &lt;span style="color: maroon; "&gt;a&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt; &lt;span style="color: silver; "&gt;=&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Au_id&lt;/span&gt;
&lt;br /&gt;       &lt;span style="color: blue; "&gt;INNER&lt;/span&gt; &lt;span style="color: blue; "&gt;JOIN&lt;/span&gt; &lt;span style="color: maroon; "&gt;TITLES&lt;/span&gt; &lt;span style="color: maroon; "&gt;t&lt;/span&gt;
&lt;br /&gt;         &lt;span style="color: blue; "&gt;ON&lt;/span&gt; &lt;span style="color: maroon; "&gt;ta&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title_id&lt;/span&gt; &lt;span style="color: silver; "&gt;=&lt;/span&gt; &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title_id&lt;/span&gt;
&lt;br /&gt;&lt;span style="color: blue; "&gt;WHERE&lt;/span&gt;  &lt;span style="color: maroon; "&gt;t&lt;/span&gt;&lt;span style="color: silver; "&gt;.&lt;/span&gt;&lt;span style="color: maroon; "&gt;Title&lt;/span&gt; &lt;span style="color: blue; "&gt;LIKE&lt;/span&gt; &lt;span style="color: maroon; "&gt;‘&lt;/span&gt;&lt;span style="color: silver; "&gt;%&lt;/span&gt;&lt;span style="color: maroon; "&gt;Computer&lt;/span&gt;&lt;span style="color: silver; "&gt;%&lt;/span&gt;&lt;span style="color: maroon; "&gt;’&lt;/span&gt; 
&lt;/span&gt;&lt;/div&gt;

&lt;h3&gt;
Do not use column numbers in the ORDER BY clause
&lt;/h3&gt;
Always use column names in an order by clause. Avoid positional references. Consider the following example in which the second query is more readable than the first one:
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;font color="blue"&gt;SELECT&lt;/font&gt; &lt;font color="maroon"&gt;OrderID&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt; &lt;font color="maroon"&gt;OrderDate&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;FROM&lt;/font&gt; &lt;font color="maroon"&gt;Orders&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;ORDER&lt;/font&gt; &lt;font color="blue"&gt;BY&lt;/font&gt; &lt;font color="black"&gt;2&lt;/font&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;font color="blue"&gt;SELECT&lt;/font&gt; &lt;font color="maroon"&gt;OrderID&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt; &lt;font color="maroon"&gt;OrderDate&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;FROM&lt;/font&gt; &lt;font color="maroon"&gt;Orders&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;ORDER&lt;/font&gt; &lt;font color="blue"&gt;BY&lt;/font&gt; &lt;font color="maroon"&gt;OrderDate&lt;/font&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;h3&gt;
Always use a column list in your INSERT statements
&lt;/h3&gt;
Always specify the target columns when executing an insert command. This helps in avoiding problems when the table structure changes (like adding or dropping a column). 

Consider the following table:
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;span style="color: blue; "&gt;CREATE&lt;/span&gt; &lt;span style="color: blue; "&gt;TABLE&lt;/span&gt; &lt;span style="color: maroon; "&gt;EUROPEANCOUNTRIES&lt;/span&gt;
&lt;br /&gt;  &lt;span style="color: maroon; "&gt;(&lt;/span&gt;
&lt;br /&gt;     &lt;span style="color: maroon; "&gt;Countryid&lt;/span&gt;   &lt;span style="color: black; font-style: italic; "&gt;INT&lt;/span&gt; &lt;span style="color: blue; "&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue; "&gt;KEY&lt;/span&gt;&lt;span style="color: silver; "&gt;,&lt;/span&gt;
&lt;br /&gt;     &lt;span style="color: maroon; "&gt;Countryname&lt;/span&gt; &lt;span style="color: black; font-style: italic; "&gt;VARCHAR&lt;/span&gt;&lt;span style="color: maroon; "&gt;(&lt;/span&gt;&lt;span style="color: black; "&gt;25&lt;/span&gt;&lt;span style="color: maroon; "&gt;)&lt;/span&gt;
&lt;br /&gt;  &lt;span style="color: maroon; "&gt;)&lt;/span&gt; 
&lt;/span&gt;&lt;/div&gt;

Here’s an INSERT statement without a column list , that works perfectly:

&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;font color="blue"&gt;INSERT&lt;/font&gt; &lt;font color="blue"&gt;INTO&lt;/font&gt; &lt;font color="maroon"&gt;EuropeanCountries&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;VALUES&lt;/font&gt; &lt;font color="maroon"&gt;(&lt;/font&gt;&lt;font color="black"&gt;1&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt; &lt;font color="maroon"&gt;‘Ireland’&lt;/font&gt;&lt;font color="maroon"&gt;)&lt;/font&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;

Now, let’s add a new column to this table:
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;font color="blue"&gt;ALTER&lt;/font&gt; &lt;font color="blue"&gt;TABLE&lt;/font&gt; &lt;font color="maroon"&gt;EuropeanCountries&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;ADD&lt;/font&gt; &lt;font color="maroon"&gt;EuroSupport&lt;/font&gt; &lt;font color="black"&gt;&lt;i&gt;bit&lt;/i&gt;&lt;/font&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;

Now run the above INSERT statement. You get the following error from SQL Server:

	Server: Msg 213, Level 16, State 4, Line 1

	Insert Error: Column name or number of supplied values does not match table definition. 
		
This problem can be avoided by writing an INSERT statement with a column list as shown below:

&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;font color="blue"&gt;INSERT&lt;/font&gt; &lt;font color="blue"&gt;INTO&lt;/font&gt; &lt;font color="maroon"&gt;EuropeanCountries&lt;/font&gt;
&lt;br /&gt;&lt;font color="maroon"&gt;(&lt;/font&gt;&lt;font color="maroon"&gt;CountryID&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt; &lt;font color="maroon"&gt;CountryName&lt;/font&gt;&lt;font color="maroon"&gt;)&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;VALUES&lt;/font&gt; &lt;font color="maroon"&gt;(&lt;/font&gt;&lt;font color="black"&gt;1&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt; &lt;font color="maroon"&gt;‘England’&lt;/font&gt;&lt;font color="maroon"&gt;)&lt;/font&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;h3&gt;
Don't ever use double quotes in your T-SQL code
&lt;/h3&gt;
Use single quotes for string constants. If it's necessary to qualify an object name, use (non-ANSI SQL standard) brackets around the name, like table name: ORDER DETAILS in this SQL.

&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
&lt;font color="blue"&gt;SELECT&lt;/font&gt; &lt;font color="maroon"&gt;od&lt;/font&gt;&lt;font color="silver"&gt;.&lt;/font&gt;&lt;font color="maroon"&gt;[Discount]&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt;
&lt;br /&gt;       &lt;font color="maroon"&gt;od&lt;/font&gt;&lt;font color="silver"&gt;.&lt;/font&gt;&lt;font color="maroon"&gt;[Quantity]&lt;/font&gt;&lt;font color="silver"&gt;,&lt;/font&gt;
&lt;br /&gt;       &lt;font color="maroon"&gt;od&lt;/font&gt;&lt;font color="silver"&gt;.&lt;/font&gt;&lt;font color="maroon"&gt;[Unitprice]&lt;/font&gt;
&lt;br /&gt;&lt;font color="blue"&gt;FROM&lt;/font&gt;   &lt;font color="maroon"&gt;[northwind]&lt;/font&gt;&lt;font color="silver"&gt;.&lt;/font&gt;&lt;font color="maroon"&gt;[dbo]&lt;/font&gt;&lt;font color="silver"&gt;.&lt;/font&gt;&lt;font color="maroon"&gt;[ORDER DETAILS]&lt;/font&gt; &lt;font color="blue"&gt;AS&lt;/font&gt; &lt;font color="maroon"&gt;od&lt;/font&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;h3&gt;
Do not prefix your stored procedure names with “sp_”
&lt;/h3&gt;
The prefix sp_ is reserved for system stored procedure that ship with SQL Server. Whenever SQL Server encounters a procedure name starting with sp_, it first tries to locate the procedure in the master database, then it looks for any qualifiers (database, owner) provided, then it tries dbo as the owner. 

So you can really save time in locating the stored procedure by avoiding the “sp_” prefix.

&lt;h3&gt;
Always use a SQL formatter to format your sql like &lt;a href="http://www.dpriver.com/pp/sqlformat.htm"&gt;Instant SQL Formatter&lt;/a&gt;(Free and Online)
&lt;/h3&gt;

The formatting of SQL code may not seem that important,but consistent formatting makes it easier for others to scan and understand your code. 

SQL statements have a structure, and having that structure be visually evident makes it much easier to locate and verify various parts of the statements. 

Uniform formatting also makes it much easier to add sections to and remove them from complex T-SQL statements for debugging purposes.

&lt;a href="http://www.dpriver.com/pp/sqlformat.htm"&gt;Instant SQL Formatter&lt;/a&gt; is a free online SQL tidy tool that makes your SQL script readable instantly.

&lt;img src="http://weblogs.sqlteam.com/jamesw/aggbug/61355.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Wang</dc:creator>
            <guid>http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best-practices.aspx</guid>
            <pubDate>Tue, 04 Oct 2011 07:38:57 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best-practices.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jamesw/comments/commentRss/61355.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Datatypes translation between Oracle and SQL Server part 2: number</title>
            <link>http://weblogs.sqlteam.com/jamesw/archive/2010/08/04/datatypes-translation-between-oracle-and-sql-server-part-2-number.aspx</link>
            <description>&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;This is an article in the series that we talking about &lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/"&gt;translate SQL query among different databases&lt;/a&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; This article focus on the translation of number datatype between oracle and SQL Server database. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; The main difference of number datatype between oracle and SQL Server is  float. ANSI SQL requires float precision to be specified in terms of  binary bits. But the number of binary bits specified in float definition  of Oracle and SQL Server doesn’t have the same meanings. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; In SQL Server, syntax of float datatype is float[(n)], Where n is the  number of bits that are used to store the mantissa of the float number  in scientific notation and, therefore, dictates the precision and  storage size. If n is specified, it must be a value between 1 and 53.  The default value of n is 53. SQL Server treats n as one of two possible  values. If 1&amp;lt;=n&amp;lt;=24, n is treated as 24. If 25&amp;lt;=n&amp;lt;=53, n is  treated as 53. The SQL Server float[(n)] data type complies with the  ISO standard for all values of n from 1 through 53. The synonym for  double precision is float(53). &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; Oracle uses its NUMBER datatype internally to represent float. precision  of Oracle FLOAT range from 1 to 126 in binary bits, The maximum of 126  digits of binary precision is roughly equivalent to 38 digits of decimal  precision which is used by NUMBER datatype. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; From this article &lt;a href="http://www.ixora.com.au/notes/number_representation.htm?number=-12.3#example"&gt;“Internal representation of the NUMBER datatype”&lt;/a&gt;,  you may agree with me that the number of binary bits specified in float  definition of Oracle and SQL Server doesn’t have the same meanings. I  don’t know how to map n in SQL server (1&amp;lt;=n&amp;lt;=53) to size in  Oracle(1&amp;lt;=size&amp;lt;=126). If anybody know this, please kindly &lt;a href="mailto:info@dpriver.com"&gt;send me an email&lt;/a&gt;. But &lt;a href="http://msdn.microsoft.com/en-us/library/ms151817.aspx"&gt;this article&lt;/a&gt;&lt;/font&gt; &lt;font size="3"&gt;tells me how to map float from Oracle to SQL Server, &lt;/font&gt;&lt;/p&gt;
&lt;pre style="font-family: Arial;"&gt;&lt;font size="3"&gt;float -&amp;gt; float&lt;br /&gt;float(1-53) -&amp;gt; float(1-53)&lt;br /&gt;float(54-126) -&amp;gt; float&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;and &lt;a href="http://download.oracle.com/docs/cd/B19306_01/gateways.102/b14270/apa.htm"&gt;this article&lt;/a&gt; tells me how to map float from SQL Server to Oracle.&lt;/font&gt;&lt;/p&gt;
&lt;pre style="font-family: Arial;"&gt;&lt;font size="3"&gt;float -&amp;gt; float(49)&lt;br /&gt;real, float(24) -&amp;gt; float(23)&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;   &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; Oracle allows numbers to be defined with a scale greater than the  precision, such as NUMBER(4,5), but SQL Server requires the precision to  be equal to or greater than the scale. To ensure there is no data  truncation, if the scale is greater than the precision at the Oracle database, the precision is set equal to the scale when the data type is  mapped: NUMBER(4,5) would be mapped as NUMERIC(5,5). &lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt; &lt;/p&gt;
&lt;div id="comparet" style="font-family: Arial;"&gt;
&lt;table border="1" style="width: 378px; height: 279px;"&gt;
    &lt;caption&gt;&lt;font size="3"&gt;Number datatype convert from Oracle to SQL Server&lt;/font&gt;&lt;/caption&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;Oracle(source)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;SQL Server(target)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;number&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;number([1-38])&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;numeric([1-38])&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;number([0-38],[1-38])&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;numeric([0-38],[1-38])&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;float([1-53])&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float([1-53])&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;float([54-126])&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;binary_float&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;binary_double&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float(53)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;int&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;numeric(38)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;real&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;table border="1" style="width: 373px; height: 298px;"&gt;
    &lt;caption&gt;&lt;br /&gt;
    &lt;font size="3"&gt;&lt;br style="font-family: Arial;" /&gt;
    &lt;span style="font-family: Arial;"&gt;Number datatype convert from SQL Server to Oracle&lt;/span&gt;&lt;/font&gt;&lt;/caption&gt;
    &lt;tbody style="font-family: Arial;"&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;SQL Server(source)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;Oracle(target)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;bigint&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(19)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;int&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(10)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;smallint&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(5)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;tinyint&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(3)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;bit&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(3)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;numeric&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(p[,s])&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;money&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;number(19,4)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;smallmoney&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;NUMBER(10,4)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;float&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;FLOAT(49)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;real&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;FLOAT(23)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;font size="3"&gt;&lt;span style="font-family: Arial;"&gt;Reference:&lt;/span&gt;&lt;br style="font-family: Arial;" /&gt;
&lt;span style="font-family: Arial;"&gt; 1. &lt;/span&gt;&lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/oracle-datatypes/" style="font-family: Arial;"&gt;Oracle datatypes&lt;/a&gt;&lt;br style="font-family: Arial;" /&gt;
&lt;span style="font-family: Arial;"&gt; 2. &lt;/span&gt;&lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/sql-server-datatypes/" style="font-family: Arial;"&gt;SQL Server datatypes&lt;/a&gt;&lt;/font&gt;&lt;img src="http://weblogs.sqlteam.com/jamesw/aggbug/61179.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Wang</dc:creator>
            <guid>http://weblogs.sqlteam.com/jamesw/archive/2010/08/04/datatypes-translation-between-oracle-and-sql-server-part-2-number.aspx</guid>
            <pubDate>Wed, 04 Aug 2010 14:36:11 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/jamesw/archive/2010/08/04/datatypes-translation-between-oracle-and-sql-server-part-2-number.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jamesw/comments/commentRss/61179.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Datatypes translation between Oracle and SQL Server part 1: character, binary strings</title>
            <link>http://weblogs.sqlteam.com/jamesw/archive/2010/07/28/datatypes-translation-between-oracle-and-sql-server-part-1.aspx</link>
            <description>&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;Datatypes translation is one of the most important things you need to consider when migrate your application from one database to the other. &lt;/font&gt;&lt;font size="3"&gt;This is an article in the series that &lt;/font&gt;&lt;font size="3"&gt;we talking about &lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/"&gt;translate SQL query among different databases.&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; This article will focused on conversion of those datatypes: character, binary strings between Oracle and SQL Server. We will talk about conversion of other datatypes such as nunber, float, date and etc in other articles later. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;When you convert character datatypes from Oracle to SQL Server or vice verse, you not only need to find corresponding datatype name but also need to find out how string was stored in database. Is this string stored in character or byte? and you must be aware of the maximum length of datatype in source and target databases. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;In SQL Server, char [ ( n ) ] is fixed-length, non-Unicode character data with a length of n bytes. n must be a value from 1 through 8,000. You can easily find corresponding datatype name “char” in Oracle, but char in oracle with a maximum length of 2000 bytes. So you can’t migrate char(2048) in your SQL Server script to Oracle without any changes, you should use clob instead if n &amp;gt; 2000. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt;In Oracle database, char[(size)] can be also be used in fixed-length character data of length size in characters. When you use char qualifier, for example char(10 char), then you supply the column length in characters. A character is technically a code point of the database character set. Its size can range from 1 byte to 4 bytes, depending on the database character set. When translate this datatype to SQL Server, target datatype can be char(10) or char(40) depends on the database character set in source database(Oracle). &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; Detailed information about &lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/oracle-datatypes/"&gt;Oracle datatypes&lt;/a&gt; and &lt;a href="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/translate-sql-query-between-different-databases/sql-server-datatypes/"&gt;SQL Server datatypes&lt;/a&gt;:  including datatype name, description and what’s the corresponding datatype in other databases. &lt;/font&gt;&lt;/p&gt;
&lt;p style="font-family: Arial;"&gt;&lt;font size="3"&gt; Below are summary tables show how Character and binary string datatypes translated from Oracle to SQL Server and vice verse. &lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;table border="1"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;Oracle(source)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;SQL Server(target)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;CHAR [(size [BYTE | CHAR])]&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;char[(size)]&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;VARCHAR2(size [BYTE | CHAR])&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varchar(size)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;NCHAR[(size)]&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;nchar[(size)]&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;NVARCHAR2(size)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;nvarchar(size)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;long&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varchar(max)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;long raw&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varbinary(max)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;raw(size)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varbinary(size)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;blob&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varbinary(max)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;clob&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varchar(max)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;nclob&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;ntext&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;bfile&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;N/A&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
&lt;font size="3"&gt;&lt;span style="font-family: Arial;"&gt;How Character and binary string datatypes translated from SQL Server to Oracle. &lt;/span&gt;&lt;br /&gt;
&lt;/font&gt;
&lt;table border="1"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;SQL Server(source)&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;Oracle(target)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;char [ ( n ) ] &lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;char[(n)], 1&amp;lt;=n&amp;lt;=2000; clob, n&amp;gt;2000&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;varchar [ ( n | max ) ] &lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;varchar2(n), 1&amp;lt;=n&amp;lt;=4000; clob (n&amp;gt;4000)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;text&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;clob&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;nchar [ ( n ) ] &lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;nchar[(n)], 1&amp;lt;=n&amp;lt;=2000; nclob(n&amp;gt;2000)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;nvarchar [ ( n | max ) ]&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;nvarchar2[(n)], 1&amp;lt;=n&amp;lt;=4000; nclob( n&amp;gt;4000 )&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;ntext&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;nclob&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;binary [ ( n ) ]&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;raw(1)(n was omitted); raw(n), 1&amp;lt;=n&amp;lt;=2000; blob(n&amp;gt;2000)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;varbinary [ ( n | max) ] &lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;raw(1)(n was omitted); raw(n), 1&amp;lt;=n&amp;lt;=2000; blob(n&amp;gt;2000)&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;font size="3"&gt;image&lt;/font&gt;&lt;/td&gt;
            &lt;td&gt;&lt;font size="3"&gt;blob&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;img src="http://weblogs.sqlteam.com/jamesw/aggbug/61175.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Wang</dc:creator>
            <guid>http://weblogs.sqlteam.com/jamesw/archive/2010/07/28/datatypes-translation-between-oracle-and-sql-server-part-1.aspx</guid>
            <pubDate>Thu, 29 Jul 2010 07:07:18 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/jamesw/archive/2010/07/28/datatypes-translation-between-oracle-and-sql-server-part-1.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jamesw/comments/commentRss/61175.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tidy sql posted on your blog</title>
            <link>http://weblogs.sqlteam.com/jamesw/archive/2009/07/28/60970.aspx</link>
            <description>As a sql developer, DBA.  we often post sql code on our blog.    Take this sql for example,&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;select pub_name, count(qty) as orders, sum(qty) as total &lt;br /&gt;from sales inner join titles on (sales.title_id=titles.title_id) &lt;br /&gt;right join publishers on (publishers.pub_id=titles.pub_id) &lt;br /&gt;group by pub_name&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;It's really difficult for others to read. and how about this one after beautify previous sql:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;code&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt;   &lt;span style="color: maroon;"&gt;pub_name&lt;/span&gt;&lt;span style="color: silver;"&gt;,&lt;/span&gt; &lt;br /&gt;
         &lt;span style="color: fuchsia; font-style: italic;"&gt;Count&lt;/span&gt;&lt;span style="color: maroon;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;qty&lt;/span&gt;&lt;span style="color: maroon;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: maroon;"&gt;orders&lt;/span&gt;&lt;span style="color: silver;"&gt;,&lt;/span&gt; &lt;br /&gt;
         &lt;span style="color: fuchsia; font-style: italic;"&gt;Sum&lt;/span&gt;&lt;span style="color: maroon;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;qty&lt;/span&gt;&lt;span style="color: maroon;"&gt;)&lt;/span&gt;   &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: maroon;"&gt;total&lt;/span&gt; &lt;br /&gt;
&lt;span style="color: blue;"&gt;FROM&lt;/span&gt;     &lt;span style="color: maroon;"&gt;sales&lt;/span&gt; &lt;br /&gt;
         &lt;span style="color: blue;"&gt;INNER&lt;/span&gt; &lt;span style="color: blue;"&gt;JOIN&lt;/span&gt; &lt;span style="color: maroon;"&gt;titles&lt;/span&gt; &lt;br /&gt;
           &lt;span style="color: blue;"&gt;ON&lt;/span&gt; &lt;span style="color: maroon;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;sales&lt;/span&gt;&lt;span style="color: silver;"&gt;.&lt;/span&gt;&lt;span style="color: maroon;"&gt;title_id&lt;/span&gt; &lt;span style="color: silver;"&gt;=&lt;/span&gt; &lt;span style="color: maroon;"&gt;titles&lt;/span&gt;&lt;span style="color: silver;"&gt;.&lt;/span&gt;&lt;span style="color: maroon;"&gt;title_id&lt;/span&gt;&lt;span style="color: maroon;"&gt;)&lt;/span&gt; &lt;br /&gt;
         &lt;span style="color: blue;"&gt;RIGHT&lt;/span&gt; &lt;span style="color: blue;"&gt;JOIN&lt;/span&gt; &lt;span style="color: maroon;"&gt;publishers&lt;/span&gt; &lt;br /&gt;
           &lt;span style="color: blue;"&gt;ON&lt;/span&gt; &lt;span style="color: maroon;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;publishers&lt;/span&gt;&lt;span style="color: silver;"&gt;.&lt;/span&gt;&lt;span style="color: maroon;"&gt;pub_id&lt;/span&gt; &lt;span style="color: silver;"&gt;=&lt;/span&gt; &lt;span style="color: maroon;"&gt;titles&lt;/span&gt;&lt;span style="color: silver;"&gt;.&lt;/span&gt;&lt;span style="color: maroon;"&gt;pub_id&lt;/span&gt;&lt;span style="color: maroon;"&gt;)&lt;/span&gt; &lt;br /&gt;
&lt;span style="color: blue;"&gt;GROUP&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: maroon;"&gt;pub_name&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(0, 0, 0);"&gt;Yes, it's really good for your readers. &lt;br /&gt;
&lt;br /&gt;
Now, you can do this instantly with the help of a free online sql formatter:&lt;br /&gt;
&lt;a href="http://www.dpriver.com/pp/sqlformat.htm" target="_blank"&gt;&lt;br /&gt;
http://www.dpriver.com/pp/sqlformat.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
1. Paste original sql code into input sql text box, then select corresponding database type, and output type(sql(html:span) should be ok).&lt;br /&gt;
&lt;br /&gt;
2. Click "format sql" button&lt;br /&gt;
&lt;br /&gt;
3. Copy Html code from text box at the bottom of that page.&lt;br /&gt;
&lt;br /&gt;
4. In your FCKeditor(If you're using SUBTEXT which is used by sqlteam weblogs), switch to source code mode by click "source code icon" in the up-left corner,&lt;br /&gt;
then paste html code, after that switch back to normal mode by click that button again.&lt;br /&gt;
&lt;br /&gt;
5. You are done.&lt;br /&gt;
&lt;br /&gt;
I think it should as easy as this to tidy sql in other blog systems like wordpress, community server. Anyway, I will check those blogs system, and let you know the result in next following days.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/code&gt;&lt;img src="http://weblogs.sqlteam.com/jamesw/aggbug/60970.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Wang</dc:creator>
            <guid>http://weblogs.sqlteam.com/jamesw/archive/2009/07/28/60970.aspx</guid>
            <pubDate>Tue, 28 Jul 2009 17:31:36 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/jamesw/archive/2009/07/28/60970.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jamesw/comments/commentRss/60970.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>