Thursday, May 1, 2014

Create a View based on data stored in a Variable


Yes thanks i have created a store proc . The result set returns dynamic column. I need to do a select from the store proc output .



Permit to quote a line the song "Width of a Circle" from David Bowie's second album, "The Man Who Sold the World": Turn around, go back!


You have obviously gone wrong somewhere earlier in you adventures. Once you have generated something like a dynamic table there is only one thing you can do with it: return it to the client.


In a relational database a table is supposed to model a unique entity, and each column is supposed to model a unique attribute, and SQL is designed from this perspective. Things like dynamic tables are awfully painful to work with, because they are completelyl out of the scope that relational databases are designed for.


I have no idea what you are up to, but it seems that most people who ask for this have produced a dynamic crosstab and now want to query the crosstab. Filter or whatever what you want to filter, before you pivot and you are playing by the rules.


By the way, while the original is good, there is an excellent rendition of "Width of a Circle" on the live album he released in 1973, "David Live".





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment