Showing posts with label iwant. Show all posts
Showing posts with label iwant. Show all posts

Monday, March 26, 2012

refresh view

Hello,
My problem is that I don't know how to refresh the view. Actually, what I
want to programaticaly do is something equivalant to presing the "run" butto
n
in the Enterprise manager.
A stored procedure that will do it, will also be good. But the only stored
procedure that I thought about is to drop the view and to create it again
(not a very elegant solution).
Do you know how I can solve this problem?
thanks!We could tell you, if you tell as the coding your using. "Refreshing" a view
means getting the data new, this differs in the languages.
HTH, Jens Suessmeyer.
"Liat" <Liat@.discussions.microsoft.com> schrieb im Newsbeitrag
news:83A7E9FC-9B15-4529-B49E-7EB2E27E4709@.microsoft.com...
> Hello,
> My problem is that I don't know how to refresh the view. Actually, what I
> want to programaticaly do is something equivalant to presing the "run"
> button
> in the Enterprise manager.
> A stored procedure that will do it, will also be good. But the only stored
> procedure that I thought about is to drop the view and to create it again
> (not a very elegant solution).
> Do you know how I can solve this problem?
> thanks!|||Liat
sp_refreshview stored procedure
"Liat" <Liat@.discussions.microsoft.com> wrote in message
news:83A7E9FC-9B15-4529-B49E-7EB2E27E4709@.microsoft.com...
> Hello,
> My problem is that I don't know how to refresh the view. Actually, what I
> want to programaticaly do is something equivalant to presing the "run"
button
> in the Enterprise manager.
> A stored procedure that will do it, will also be good. But the only stored
> procedure that I thought about is to drop the view and to create it again
> (not a very elegant solution).
> Do you know how I can solve this problem?
> thanks!|||I am using C++
"Jens Sü?meyer" wrote:

> We could tell you, if you tell as the coding your using. "Refreshing" a vi
ew
> means getting the data new, this differs in the languages.
> HTH, Jens Suessmeyer.
> "Liat" <Liat@.discussions.microsoft.com> schrieb im Newsbeitrag
> news:83A7E9FC-9B15-4529-B49E-7EB2E27E4709@.microsoft.com...
>
>|||Hi
View doesnt store any data. Selecting rows from a view is as good as
executing the query that created it.
We go for views because, it improves the performance of a query.
thanks and regards
Chandra
"Liat" wrote:

> Hello,
> My problem is that I don't know how to refresh the view. Actually, what I
> want to programaticaly do is something equivalant to presing the "run" but
ton
> in the Enterprise manager.
> A stored procedure that will do it, will also be good. But the only stored
> procedure that I thought about is to drop the view and to create it again
> (not a very elegant solution).
> Do you know how I can solve this problem?
> thanks!|||> We go for views because, it improves the performance of a query.
Unless you are talking about indexed views, I disagree.sql

Wednesday, March 21, 2012

Referensing an alias field within the same view

I have created an Alias field in a View using a Case statement and next I
want to reference that Alias field in another Alias field with a Case
statement. I get an error stating the first field is not valid. Example of
what I'm trying to do
Column
Alias
CASE WHEN [A] = 0 AND [B] = 1 THEN 1 ELSE 0 END Expr1
CASE WHEN [Expr1] = 1 AND [C] = 1 THEN 1 ELSE 0 END Expr2
SQL doesn't like my referencing Expr1 in the second field. I suppose I could
save the first view and then create a new view based on the first but I was
hoping there might be a way to get around that. Thanks for any help.AkAlan,
As you said, it is an alias and you can not reference it in the same column
list. May be using a derived table, a view, or rewiting the expression.
select
orderid, productid, ext_price * (1.00 - (discount / 100.00)) as exp2
from
(
select orderid, productid, quantity * unitprice as ext_price
from [order details]
) as t
go
AMB
"AkAlan" wrote:

> I have created an Alias field in a View using a Case statement and next I
> want to reference that Alias field in another Alias field with a Case
> statement. I get an error stating the first field is not valid. Example of
> what I'm trying to do
> Column
> Alias
> CASE WHEN [A] = 0 AND [B] = 1 THEN 1 ELSE 0 END Expr1
> CASE WHEN [Expr1] = 1 AND [C] = 1 THEN 1 ELSE 0 END Expr2
> SQL doesn't like my referencing Expr1 in the second field. I suppose I cou
ld
> save the first view and then create a new view based on the first but I wa
s
> hoping there might be a way to get around that. Thanks for any help.
>