Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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; 
like image 407
wabregoc Avatar asked Feb 06 '15 17:02

wabregoc


People also ask

Is there a DUAL table in SQL Server?

In SQL Server DUAL table does not exist, but you could create one. The DUAL table was created by Charles Weiss of Oracle corporation to provide a table for joining in internal views.

What is DUAL table in Microsoft SQL?

It is a table that is automatically created by Oracle Database along with the data dictionary. DUAL is in the schema of the user SYS but is accessible by the name DUAL to all users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value X.

What is the DUAL table used for in Oracle SQL?

The DUAL table is a dummy table in Oracle databases. It's used for selecting data from system functions and calculations when you don't need any data from the database.

What is the dummy table in SQL Server?

The DUMMY table is provided as a table that always has exactly one row. This can be useful for extracting information from the database, as in the following example that gets the current user ID and the current date from the database. The DUMMY table is a SQL Anywhere system table.


2 Answers

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) ) GO INSERT INTO DUAL (DUMMY) VALUES ('X') GO 
like image 116
Jean-François Savard Avatar answered Oct 05 '22 00:10

Jean-François Savard


You do not need DUAL in mssql server

in oracle

select 'sample' from dual 

is equal to

SELECT 'sample' 

in sql server

like image 22
Omer Avatar answered Oct 05 '22 01:10

Omer