﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / "Dynamic" view question / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 04:00:38 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: "Dynamic" view question</title><link>http://www.sqlservercentral.com/Forums/Topic1363687-391-1.aspx</link><description>[quote][b]Mindy Hreczuck (9/24/2012)[/b][hr]Well I'll try to explain better...One solution would be to create a UDF instead of a view and pass in a user guid into that UDF which queries the account table based on the fund mapped to that user guid.This would require that all selects to the account table would be replaced by selects to the new account UDF, however all the procedures would need a new input parameter that accepts the current user guid to be passed into the UDF.This is about as close as we as gotten to a "clean" solution, but its not ideal since we need to modify the code and procedure for the new input param.[/quote]If you post some DDL (CREATE TABLE statement) for the tables and some sample data (series of INSERT INTO statements) for each table, and the expected input/outputs maybe we could come up with something.</description><pubDate>Wed, 26 Sep 2012 01:01:02 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: "Dynamic" view question</title><link>http://www.sqlservercentral.com/Forums/Topic1363687-391-1.aspx</link><description>What you are asking about sounds like the Virtual Private Database concept available in Oracle Enterprise Edition.I'm not sure if this link will help you or not but it is what I found on Google when I searched for an equivalent in MS SQL Server.[url]http://technet.microsoft.com/en-us/library/cc966395.aspx[/url]</description><pubDate>Tue, 25 Sep 2012 21:05:08 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: "Dynamic" view question</title><link>http://www.sqlservercentral.com/Forums/Topic1363687-391-1.aspx</link><description>Well I'll try to explain better...One solution would be to create a UDF instead of a view and pass in a user guid into that UDF which queries the account table based on the fund mapped to that user guid.This would require that all selects to the account table would be replaced by selects to the new account UDF, however all the procedures would need a new input parameter that accepts the current user guid to be passed into the UDF.This is about as close as we as gotten to a "clean" solution, but its not ideal since we need to modify the code and procedure for the new input param.</description><pubDate>Mon, 24 Sep 2012 13:49:30 GMT</pubDate><dc:creator>Mindy Hreczuck</dc:creator></item><item><title>RE: "Dynamic" view question</title><link>http://www.sqlservercentral.com/Forums/Topic1363687-391-1.aspx</link><description>I'm not sure I follow you.A View is just a saved Select statement.  It can't be dynamic, really.You can sort of do a dynamic view with an inline-table UDF, which is essentially a view with input parameters.A stored procedure could take an input parameter of which type of account you want to look at, based on a value passed by the application, and could select different things from different objects (tables, views, UDFs) based on the inputs.But I'm not sure if that's what you're trying to do or not.</description><pubDate>Mon, 24 Sep 2012 13:07:34 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>"Dynamic" view question</title><link>http://www.sqlservercentral.com/Forums/Topic1363687-391-1.aspx</link><description>We have a existing system full of accounts.  There is a requirement that any new accounts are to be divided into "Funds".  Initially two funds will be created.  An account can be in either fund 1 or fund 2, and possibly both.  We decided that a mapping table of funds and accounts be sufficient for this.A front end instance can be logging into just one fund at a time.Now comes the tricky part.  We need to change the code to reflect this new behavior.  We think replacing any select to the Account table with a view that joins on account and fund will do the trick. (it would return just the account rows specific to that fund) When a user logs into the UI they will select the fund they want to view.  What's the best option to allow the view to display the correct fund dynamically?  Keep in mind the user could have two different instances open with different fund accounts.  (we envision this to be default behavior for most users)  We want to avoid having to change the where clause in all our queries.Any ideas?</description><pubDate>Mon, 24 Sep 2012 12:59:03 GMT</pubDate><dc:creator>Mindy Hreczuck</dc:creator></item></channel></rss>