Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

How do you create a view using MS SQL server Management Suite

Need to utilize an outer join and user date paramter, therefore creating a view to provide the user to query with a date paramter.
0
bradleydandrews
Asked:
bradleydandrews
  • 2
  • 2
  • 2
  • +1
1 Solution
 
jorge_torizResearch & Development ManagerCommented:
Well, the views cannot be parametrized, that is the first point, in that case you must use tabular functions
0
 
SharathData EngineerCommented:
You can create a view in SSMS by right click on Views folder in your database. A window will be opened, from where you can pick existing tables/views/Functions/Synonyms for the creation of your view.

>> therefore creating a view to provide the user to query with a date paramter.
If you want to pass a date parameter in the SELECT query of your view, you can create a stored procedure and pass the date as parameter.
0
 
BrandonGalderisiCommented:
http:#22707820 is correct.  You can't really use a view for this.  You would want to create a procedure.



create procedure up_MyProc
 @DateParam datetime
as
set nocount on
select t1.col1, t2.col2, t3.col3
from table1 t1
join table2 t2 
on t1.id=t2.id
join table3 t3
on t2.id2 = t3.id2
where t3.YourDateField = @DateParam
go
 
--then execute it like this:
exec up_MyProc '20081013'

Open in new window

0
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

 
jorge_torizResearch & Development ManagerCommented:
I prefer to use tabular functions, if you want to join your query results you will have to do some more work if you use stored procedures.

Tabular functions are made for that... stored procedures are used to perform changes in databases... is the common sense
0
 
bradleydandrewsAuthor Commented:
Not having a solid SQL background, I chose to create an Excel Pivot Table built on an OLAP cube. The user then can alter the date inclusion using the page dropdown.
0
 
BrandonGalderisiCommented:
But http:#22707806, http:#22707881 and http:#22707820 gave good responses.
0
 
bradleydandrewsAuthor Commented:
I agreed with the solution, however the answer clearly begged for another question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now