How can i create a view in SQL Server,where columns are defined and appear according to a value stored in another table.These columns are almost identically calculated by a function but their number is set from another table’s record.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not possible with a view because SQL Server queries are always statically typed in the sense that both column count, names and types are statically known at execution time.
You need dynamic SQL for dynamic columns.
Views do not support dynamic SQL. You have to find some other way of returning the data, maybe with one row per logical column.