Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • 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_torizCommented:
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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
jorge_torizCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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