Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Bright
Starting Member
4 Posts |
Posted - 2015-01-14 : 03:21:17
|
I need to understand if someone faced any issues related to working on SQL or what are the interesting or challenging issues that are faced. And how one was able to resolve it. Please if anyone can let me understand so that it will be helpful not only in knowledge but also in interview point of view too.Thnks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-01-14 : 12:01:18
|
I face interesting and challenging issues everyday, so you'll need to be more specific.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Bright
Starting Member
4 Posts |
Posted - 2015-01-14 : 15:22:13
|
I have this stored Pro., for example..Besides lack of documentation to explain what it does.My challenge is to explain what else is complex about it.I have no work experience, and I am learning how to write a Complex stored procedure & to be able to explain it.create procedure Whileloopexample@Territoryname VARCHAR( 100)ASbEGINSET NOCOUNT ONselect Distinct YEAR(OrderDate) as Orderyear into #SalesYears FROM SALES.SalesOrderHeaderOrder by Year(Orderdate) ascDeclare @Year intset @Year=(SELECT TOP 1 OrderYear FROM #SalesYears)Create table #Result1 (Productname varchar(200),Total money,TerritoryName varchar(100),[Year] int)while @year is not null BEGINInsert into #Result1 (Productname, Total, TerritoryName,[year])Select Top 5 d.Name as Productname,sum(a.LineTotal)as Total,c.Name as TerritoryName, year(b.Orderdate) as [Year]from Sales.SalesOrderDetail ainner join Sales.SalesOrderHeader b on a.SalesOrderID=b.SalesOrderIDINNER JOIN Production.Product d ON a.ProductID = d.ProductIDInner join Sales.SalesTerritory c on b.TerritoryID=c.TerritoryIDWhere Year(b.OrderDate)= @year and c.Name = @Territorynamegroup by d.Name,c.Name,b.Orderdateorder by SUM(LineTotal) descDelete from #SalesYears WHERE [Orderyear] = @Yearset @Year= ( Select Top 1 orderyear from #SalesYears)ENDSELECT * FROM #Result1ENDexec Whileloopexample 'Northwest' |
|
|
|
|
|
|
|