January 13, 2006 at 3:55 am
Hi,
I'm fairly new to SQL Server and need some help with Views.
I need to find out whether you can alter a view dynamically. I need to add the word 'distinct' to the select clause if a value in a table is set to 1.
So if "Show links"=1 for a particular user then my view should have a select statement of..."SELECT DISTINCT [columns]...". But if the "Show links"=0 then it should read "SELECT [columns]...". This is also the same for the 'Where' clause in that I need to extend the current where clause depending on the value in the "Show Links" column.
Does anybody have any ideas?
Thanks in advance
January 13, 2006 at 4:49 am
I would put the view in a stored procedure with an input parameter called @Show_links
Then apply the following logic...
If @Show_links =0
then
Select distinct......
end
If @Show_links =1
then
Select .........
end
I hope this helps
Andy.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply