What is the equivalent of the Oracle "Dual" table in MS SqlServer?
In sql-server
, there is no dual
you can simply do
SELECT pCliente, 'xxx.x.xxx.xx' AS Servidor, xxxx AS Extension, xxxx AS Grupo, xxxx AS Puerto
However, if your problem is because you transfered some code from Oracle
which reference to dual
you can re-create the table :
CREATE TABLE DUAL(DUMMY VARCHAR(1))GOINSERT INTO DUAL (DUMMY)VALUES ('X')GO
You do not need DUAL in mssql server
in oracle
select 'sample' from dual
is equal to
SELECT 'sample'
in sql server
While you usually don't need a DUAL
table in SQL Server as explained by Jean-François Savard, I have needed to emulate DUAL
for syntactic reasons in the past. Here are three options:
Create a DUAL
table or view
-- A tableSELECT 'X' AS DUMMY INTO DUAL;-- A viewCREATE VIEW DUAL AS SELECT 'X' AS DUMMY;
Once created, you can use it just as in Oracle.
Use a common table expression or a derived table
If you just need DUAL
for the scope of a single query, this might do as well:
-- Common table expressionWITH DUAL(DUMMY) AS (SELECT 'X')SELECT * FROM DUAL-- Derived tableSELECT *FROM ( SELECT 'X') DUAL(DUMMY)