ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

There's a problem to Use ALTER Query to Rename the Table

Hi.

 

I was trying to rename my table by query. 

 

So I found 'ALTER TABLE old_table_name RENAME TO new_table_name;' query on the internet.

 

But it cause error.

 

I try other functions like

 

ALTER TABLE name DROP [COLUMN] column_name 
ALTER TABLE name ADD COLUMNS

and it work fine.

 

I don't know why I can't change my Table by 'ALTER' statement.

 

Is there anybody know the reason?

 

 

0 Kudos
Message 1 of 8
(4,310 Views)

Try sp_rename

0 Kudos
Message 2 of 8
(4,259 Views)

It would be useful to know the error...

 

What database are you using? Apparently MySQL uses a different syntax.

0 Kudos
Message 3 of 8
(4,256 Views)

I’m working with Access. 

0 Kudos
Message 4 of 8
(4,246 Views)

https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/alter-tab...

"

Note

The Microsoft Access database engine does not support the use of ALTER TABLE, or any of the data definition language (DDL) statements, with non-Microsoft Access databases. Use the DAO Create methods instead."

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 8
(4,241 Views)

You can Select everything and drop it into a new table, then drop the old, that'd effectively be a rename.

SELECT *
INTO [acecodetable].['PSCLineReason']
FROM [acecodetable].['15_PSCLineReason'];

DROP [acecodetable].['15_PSCLineReason']

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(4,235 Views)

So there No way to Rename the Table by ALTER Query.

 

Thanks guys


0 Kudos
Message 8 of 8
(4,201 Views)