How do I create a view dynamically in SQL Server using C#?
+3
A:
query = " Create View [Viewname] Select ....";
Execute the query...
Samiksha
2008-12-03 10:19:48
+1
A:
Something like this, obviously your connection code will be different (better):
SqlConnection conn = null;
conn = new SqlConnection("yourConnectionString");
conn.Open();
string strSQLCommand = "CREATE VIEW vw_YourView AS SELECT YOurColumn FROM YourTable";
SqlCommand command = new SqlCommand(strSQLCommand, conn);
string returnvalue = (string)command.ExecuteScalar();
conn.Close();
Coolcoder
2008-12-03 11:33:40