In MySQL I could execute the following:
SELECT "spam" AS "foo", "eggs" AS "bar" LIMIT 1;
...which would return 1 row with 2 columns ("foo" and "bar) and 2 values ("spam" and "eggs").
Is it possible to do this with TSQL in SQL Server?
You can do any of these:
SELECT 'spam' foo, 'eggs' bar
SELECT 'spam' AS foo, 'eggs' AS bar
SELECT foo = 'spam', bar = 'eggs'
SELECT 'spam' "foo", 'eggs' "bar"
SELECT 'spam' [foo], 'eggs' [bar]
Since you're building a hard-coded set of values you don't need a limiting clause. Just FYI, the equivalent in T-SQL is TOP
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With