Author |
Topic |
koushik
Starting Member
11 Posts |
Posted - 2010-09-14 : 08:10:24
|
Hi,Can you please let me know how to alter a view from a procedure code.Regards,Koushik Chandra |
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2010-09-14 : 08:30:54
|
use execute immedaiate |
 |
|
koushik
Starting Member
11 Posts |
Posted - 2010-09-14 : 08:46:41
|
Can you please provide the syntax for this as the "Immediate" is seems to be not a keyword in SQL Server 2005Regards,Koushik Chandra |
 |
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2010-09-14 : 09:05:59
|
declare @sql as nvarchar(100)set @sql='select * from tbl_UserRoles'EXECUTE sp_executesql @sql |
 |
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2010-09-14 : 09:16:00
|
declare @sql as nvarchar(100)set @sql='create view testview as select * from tbl_UserRoles'EXECUTE sp_executesql @sql |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-14 : 09:25:27
|
quote: Originally posted by kunal.mehta use execute immedaiate
Execute immediate is for mysql and ORACLEMadhivananFailing to plan is Planning to fail |
 |
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2010-09-14 : 09:31:32
|
use EXECUTE sp_executesql @sql for sql server |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-14 : 09:36:19
|
quote: Originally posted by koushik Hi,Can you please let me know how to alter a view from a procedure code.Regards,Koushik Chandra
Why do you want to alter a view from a stored procedure?MadhivananFailing to plan is Planning to fail |
 |
|
koushik
Starting Member
11 Posts |
Posted - 2010-09-15 : 04:34:20
|
I want to change the source table name in the alter view statement. e.g. View Created like : Create View v1 as select * from tab1In the Alter view starement I want "Alter View V1 as select * from t2"Regards,Koushik Chandra |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-15 : 09:19:48
|
quote: Originally posted by koushik I want to change the source table name in the alter view statement. e.g. View Created like : Create View v1 as select * from tab1In the Alter view starement I want "Alter View V1 as select * from t2"Regards,Koushik Chandra
You can do it as a independent statement. I dont see any point in using a Stored procedure for thisMadhivananFailing to plan is Planning to fail |
 |
|
|