Creating table having structure same as that of existing table

27/08/2003 - 06:59 por Kuntal Kumar Sasan | Informe spam
Hi,

How can I create a table (need to create temporary table) having
structure same as that of an existing table. Only need is to create table,
no need of copying data along with it.

Thanx in advance,
K.K.

Preguntas similare

Leer las respuestas

#1 Emilio Boucau
27/08/2003 - 14:43 | Informe spam
You can issue a

SELECT * INTO New_Table FROM Source_Table WHERE 1=2

This statement will copy only the orig structure.

I kindly remind you to post in Spanish in the future, not in English.

-

Podes ejecutar

SELECT * INTO New_Table FROM Source_Table WHERE 1=2

Esta sentencia copiara solamente la estrucutra original.

Te pido que en el futuro hagas tus postas en castellano, no en ingles.

Saludos !

Emilio Boucau
Microsoft MVP SQL Server
http://www.portalsql.com
PASS Spanish Group
http://www.sqlpass.org

Buenos Aires - Argentina
Respuesta Responder a este mensaje
#2 Gustavo Larriera [MVP]
27/08/2003 - 20:38 | Informe spam
Hi Kuntal,

The SELECT INTO statement creates a new table and populates it with the
result set of the SELECT. The structure of the new table is defined by the
attributes of the expressions in the select list, for example:

SELECT Shippers.*, Link.Address, Link.City,
Link.Region, Link.PostalCode
INTO NewShippers
FROM Shippers
JOIN LinkServer.DB.dbo.Shippers AS Link
ON (Shippers.ShipperID = Link.ShipperID)
SELECT INTO can be used to combine data from several tables or views into
one table. It can also be used to create a new table containing data
selected from a linked server.

As noted by Emilio, keep in mind that this is a newsgroup for spanish
messages. You should post english messages to some of the
microsft.public.sqlserver.* newsgroups.

Regards,
gux
Gustavo Larriera, MSFT MVP-SQL
Uruguay LatAm

This message is provided "AS IS" with no warranties expressed or implied,
and confers no rights.


"Kuntal Kumar Sasan" wrote in message
news:%
Hi,

How can I create a table (need to create temporary table) having
structure same as that of an existing table. Only need is to create table,
no need of copying data along with it.

Thanx in advance,
K.K.



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida