Need some help, Please! | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Need some help, Please!

Hi!! I’m really new at sql , and I’m having some troubles with sql 6.5. I need to delete a field of a table, but as I have test several times I realized that it’s not possible to delete the field, so what I thought was to create another table with the same structure but without the fields that I wanted to delete. But when I run the sintax to create the table can’t make it run, it stops because of an error which is not really clear.
I have try with this two ways: INSERT INTO TABLE_BCK SELECT (FIELD1, FIELD2, …, FIELDN) FROM TABLE — gives an error. INSERTO INTO SELECT (FIELD1, FIELD2, …, FIELDN) FROM TABLE –the same happens But if I run the query INSERT INTO TABLE_BCK SELECT * FROM TABLE — this query runs ok, without problems. The problem is that I need to delete some fields… How can I do that?
I know it might sound a really dummy question, but I don’t know how to do this, I’m a beginner, and I need some help I will really appreciate. Thanks you very much!!!!!
Hi Flo, without seeing the exact statements, its not that easy to tell, also, what are the exact errors given in the first two. Without knowing those specifics, here is what I think is happening: From reading what you posted table_bck has the exact structure of table – it has to for the select * for work.
So, if you only want to insert specific columns then use this
INSERT INTO TABLE_BCK columns (FIELD1, FIELD2, …, FIELDN)
SELECT FIELD1, FIELD2, …, FIELDN FROM TABLE There must be the same number of columns in the insert line as the select line. This is why the second one is failing. The first is failing on a syntax error. Select * works because there are the same number of columns (with matching datatypes) in table and table_bck. Chris
Thank you very much Cris!!! I’ll try this and will let you know!!!

]]>