September 12, 2017 at 2:35 pm
Hello, I have a select that used declare, and now I need to make that select a view, and I can't use declare, should I create a procedure and then call that procedure from the create view or should I create the view from within the procedure? My declares look like this:
DECLARE @actvt_dt1 DATE = '20150815';
DECLARE @actvt_dt2 DATE = '20150912';
DECLARE @actvt_dt3 DATE = '20150926';
DECLARE @actvt_dt4 DATE = '20150813';
DECLARE @actvt_dt5 DATE = '20150910';
DECLARE @actvt_dt6 DATE = '20150917';
DECLARE @actvt_dt7 DATE = '20150819';
DECLARE @actvt_dt8 DATE = '20150916';
DECLARE @actvt_dt9 DATE = '20150923';
Thanks
September 12, 2017 at 2:48 pm
CREATE VIEW StaticDataView AS
SELECT actvt_dt1 = Cast('20150815' AS date)September 12, 2017 at 3:05 pm
Need more information. Anything we say now are just shots in the dark.
September 12, 2017 at 4:11 pm
Phil Parkin - Tuesday, September 12, 2017 2:52 PMAn iTVF may do what you need.
I found a way to get around using declare and hence a function within a view. I looked at the link, and if I need to use a function in a view, this is what I will use as a resource. Thanks
If I used the function, to call the declare, it would in a sense be hard coding a a date to end up getting a number value of a date period, and it would have been wrong. Ended up using datediff and date math and have the proper increments based off a moving date, as it should be.
September 12, 2017 at 4:59 pm
Okay, so share your solution. It may benefit others to see what you did.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply