Dear Sir/Madam,
I want to create a replica of another table with all the constraints except primary key.
when i tried the command
SELECT * INTO vch1 FROM Voucher
none of the constraints like DEFAULT, NOT NULL are defined in the new table.
pl. guide me.
with regards
wilfi
not sure if this is what you are looking for. In SQL 2005 if you right click the table in SSMS then select Script Table As, then CREATE To you can script the table to a new query window. This will provide all the SQL required to create the table as well as all constraints. You can then simply remove the primary key once the table is created.
Hope this helps,
Grant|||SELECT ... INTO does NOT transfer any table constraints -it only transfers data to the new table.|||Or you can just remove the primary key constraint from the DDL that you get from the Script Table As command. Generally speaking though, it is a best practice to build your objects from a file so you can maintain the table create in version control. Then you can just use that script to recreate the table.|||
hey why dont u just right click on the table in enterprise manager and select "COPY" option and then paste in in the Query Analyser window u will get all the constraints u can then change the table name and execute
RegarDs,
Jacx
|||Thank u sir.
Yes I could do it that way. But i thought with the make table query there may be some option to carry the constraints.
thanks a lot.
with regards
wilfi
|||
Dear Jac,
Yes i could do that & i did that at last. First i thought there may be some option in the
make query to carry the constraints.
thank u.
with regards
wilfi
No comments:
Post a Comment