Search code examples
sqlsql-serveroracle-databaset-sqldual-table

What is the equivalent of the Oracle "Dual" table in MS SqlServer?


What is the equivalent of the Oracle "Dual" table in MS SqlServer?

This is my Select:

SELECT pCliente,
       'xxx.x.xxx.xx' AS Servidor,
       xxxx AS Extension,
       xxxx AS Grupo,
       xxxx AS Puerto
FROM DUAL;

Solution

  • In SQL Server, there is no dual. You can simply skip the FROM clause:

    SELECT pCliente,
           'xxx.x.xxx.xx' AS Servidor,
            xxxx AS Extension,
            xxxx AS Grupo,
            xxxx AS Puerto
    

    However, if your problem is that you transferred some code from Oracle which references dual, you may create a dummy table:

    CREATE TABLE DUAL
    (
    DUMMY VARCHAR(1)
    )
    GO
    INSERT INTO DUAL (DUMMY)
    VALUES ('X')
    GO