Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
forrestgump
Starting Member
19 Posts |
Posted - 2013-02-05 : 06:21:47
|
Hi there, I was wandering if there is a way of altering a view and adding a column. I have the following code and column which I wish to add.CASE WHEN [UKUS] IS NOT NULL THEN [UKUS] ELSE [MoW] END AS OfferMadeI have tried the following code but to no avail.ALTER VIEW Q1_GPO_DatasetADD OfferMadeCASE WHEN [UKUS] IS NOT NULL THEN [UKUS] ELSE [MoW] END AS OfferMade |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-02-05 : 06:55:18
|
ALTER VIEW is to use like CREATE VIEW. The difference is that the view does already exists. Read up in BOL. Too old to Rock'n'Roll too young to die. |
|
|
forrestgump
Starting Member
19 Posts |
Posted - 2013-02-05 : 07:37:35
|
I ended up just entering the view and then adding the code. Is this good practice? or should I really be using a different method?Regards,Forrest |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-05 : 07:43:24
|
Usually what I do is to right-click on the view name in SSMS object explorer, select Script View As -> Alter To -> New Query Editor Window. Once the window comes up, make the changes you want and execute.By "entering the view" did you mean that you used the designer (right-click and then select the menu "Design")? If that is the case, that is just as good. |
|
|
forrestgump
Starting Member
19 Posts |
Posted - 2013-02-05 : 07:49:04
|
Hi James K,Yes I did reply using design. Thanks for your reply once again. And thak you webfred as well.Regards, Forrest |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-05 : 10:14:31
|
You are welcome Forrest - Glad to help. |
|
|
|
|
|