views:

203

answers:

2

Hi. 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.........

+1  A: 

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

http://stackoverflow.com/questions/1528805/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();
hgulyan
Thanks. But, it is showing the error as cannot parse the query. I'm using visual studio 2008. I don't have front end to work with sql server 2008. . .
Nila
@Nila Check updates
hgulyan
A: 

Please copy this table and data to new table and then delete old table. Same logic with rename. insert into New_TableName select * from Old_TableName

Hnin Kyawt Wai