• 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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