1

I would like to know if it is possible to create a fake table in SQL Server 2005.

Because when I tried I got an error

Msg 208, Level 16, State 1, Line 1
Invalid object name 'dual'.

This is what I tried

and it did not work. For test purpose I have created a test table to execute the query.

Community
  • 1
  • 1
freaky
  • 294
  • 4
  • 14

1 Answers1

9

In SQL Server you are allowed to leave out the FROM clause. So you don't need a fake table.

Instead of writing

select 42
from dual;

just write

select 42;
  • Just a note on your problem: the 'dual' table is an Oracle concept, which is why it was failing for you in mssql. Personally I find ms sql server a lot simpler - as @a_horse_with_no_name said: you're allowed to 'select' without a 'from' clause. – ari Feb 15 '13 at 11:52
  • @ari: Actually several DBMS do *not* support a `SELECT` without a `FROM` (Oracle, DB2, Firebird). They all have some kind of "dual" table for that case. –  Feb 15 '13 at 12:06