June 21, 2004 at 6:49 am
Hello,
not being a SQL expert, I'm currently writting some stored procedure. I need to create a temporary table with exactly the same structure as an already existing one (via the 'SELECT * INTO
I read all I could concerning the 'SET IDENTITY_INSERT
1. First of all: are you definitively positive on the fact that you cannot remove an identity constraint in T-SQL?
2. Is there a GENERIC way of creating a
Thank you so much in advance for all your enlightment!
Edouard
June 21, 2004 at 7:48 am
Hi,
you can create a table with the same structure, initialized empty from existing one with
select * into TAB2 from TAB1 where 1=2
but identity column will be also created
vbenus
June 22, 2004 at 4:13 am
Hi, you can also build a new table based on a cursor with following SELECT:
SELECT
column_name=c.name,
datatype=t.name,
length=c.length
FROM sysobjects AS o
INNER JOIN syscolumns AS c
ON o.id = c.id
INNER JOIN systypes AS t
ON c.xtype=t.xtype
WHERE o.xtype='U'
ORDER BY o.name,c.colid
wich return column name with type and length
HTH
Gigi
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply