Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a table in the sql server compact edition

I'm new to SQL Server Compact edition. I'm using Compact edition 3.5. I tried renaming the table. But, I couldn't do that through the following query.

alter table tablename to newname

Plz, someone help me.........

like image 454
Developer404 Avatar asked May 18 '10 05:05

Developer404


2 Answers

Try this

sp_rename '[OldTableName]' , '[NewTableName]'

Check links below for more information

http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/

http://erikej.blogspot.com/2007/08/hidden-gem-rename-table.html

Good Luck!

UPDATE

Here you can find a similar question

How do I rename a table in SQL Server Compact Edition?

You can try this tool

http://www.primeworks-mobile.com/

or try this in visual studio

conn.Open();
SqlCeCommand cmd = new SqlCeCommand("sp_rename 'oldTable', 'newTable' ", conn);
cmd.ExecuteNonQuery();
conn.Close();
like image 157
hgulyan Avatar answered Sep 23 '22 22:09

hgulyan


In Visual Studio:

  1. Right click on database file in Database Explorer
  2. Select new query
  3. Type: sp_rename 'oldName' , 'newName'
  4. Press Ctrl+R key
  5. Finish
like image 33
Morteza Avatar answered Sep 21 '22 22:09

Morteza