views:

257

answers:

3

I am using Visual Studio 2008 and SQL Server 2008 Express.

How can I change the name of the view? I can change tables' names, but I can't change the view name.

Any suggestion?

Thank you, Fabio Milheiro

+1  A: 

You can use the ALTER command or CREATE a new one and delete the old one.

-Shaun

SCMcDonnell
+2  A: 

you can use the gui in sms

you can right click view, edit it, then do generate script if you want the code

mson
+3  A: 

You can use the ALTER VIEW statement something like this :

ALTER VIEW dbo.myView
AS
SELECT foo
FROM dbo.bar
WHERE widget = 'foo'
GO

Reference on MSDN

To rename a view, use sp_rename System Stored Procedure :

EXEC sp_rename 'dbo.myView', 'dbo.myNewViewName'

MaxiWheat
OK, but where do I set the new name of the myView view? Can't find it in the code you posted.
Fabio Milheiro