10

There doesn't seem to be any clear info out there about T-SQL and the ability to use it in SQLite and other non-microsoft SQL implementations. Most articles I come across say its Microsoft proprietary, so can we use T-SQL statements like CASE etc. on a SQLite database?

2 Answers 2

15

T-SQL is Microsoft's implementation (dialect) of the ANSI SQL standard. Like most implementations, there are portions that are proprietary and not standard, quirks that are permissible but not idiomatic for other platforms, items defined in the standard that are missing and not implemented, and deviations from the standard that are not compatible with other platforms. MySQL, SQLite, and others are the same way, and so sometimes a quirk with another platform will make even "correct" and standards-compliant T-SQL be broken for that platform.

In other words, if you know T-SQL, you know about 85% of what you need to write queries for SQLite, MySQL, Oracle, Postgresql, DB2, Informix, Access, etc. However, there will be a few bumps; definitely don't expect code written for one platform to work on another.

CASE is one of those instances where the various flavors of sql tend to differ, with a number of other implementations choosing a syntax based on IF instead. Date/DateTime handling is another troublesome area. The core SELECT, FROM, WHERE keywords, on the other hand, tend to be more consistent.

Sign up to request clarification or add additional context in comments.

3 Comments

TransactSQL (T-SQL) was Sybase's extension of the SQL language before Microsoft copied it, and it remains the closest thing to MSSQL Server syntax (though differences have evolved).
In addition to what hardmath said, ANSI is intended to consolidate the differences between various vendor implementations but that does not mean the entire spec is implemented, or that the functionality performs as well as pre-existing native syntax.
@hardmath just to be clear, Microsoft didn't "copy" T-SQL from Sybase, they bought it. Just don't want any false perceptions out there, as "copied" code tends to imply "stolen." en.wikipedia.org/wiki/Microsoft_SQL_Server
8

ANSI SQL is the standard Structured Query Language.

Most database vendors support SQL. T-SQL is Microsoft's version of ANSI SQL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.