Viewing 15 posts - 6,541 through 6,555 (of 8,731 total)
I forgot to mention that the CTE and ROW_NUMBER functions are not needed at all if you change to ORDER BY with OFFSET and FETCH options.
The MAXDOP option might give...
April 25, 2014 at 11:55 am
inevercheckthis2002 (4/25/2014)
Luis Cazares (4/25/2014)
More than a simple order by is needed....]Luis,
Thank you very much for the solution and for the reference.
You're welcome. Be sure to understand how the code works...
April 25, 2014 at 11:51 am
Speaking about bad coding habits :crazy:
Your code will allow sql injection. You need to parametrize your query.
You will construct your conditions like this:
if (@Date <> 0)
Begin
...
April 25, 2014 at 11:49 am
ROW_NUMBER is not designed to return data in certain order (even if it returns the rows in order most of the times when dealing with 10 rows). Your query is...
April 25, 2014 at 10:54 am
More than a simple order by is needed. You need to use CROSS TABS (or pivot if you want to complicate yourself :-P).
Here's a nice article on them: http://www.sqlservercentral.com/articles/T-SQL/63681/
And here's...
April 25, 2014 at 9:52 am
You can't guarantee and order if you don't have an ORDER BY in your query. If you have repeated values, the order won't be guaranteed either.
April 25, 2014 at 9:47 am
I would suggest that you normalize your tables and have an additional table for the telephone numbers.
What would happen if an employee has more than one cell phone? Or several...
April 25, 2014 at 8:22 am
klbaiju 94581 (4/25/2014)
Hi friend iam very eager to your reply.
You need to understand that people are in different timezones. It was 4am when you posted your reply.
To get the day...
April 25, 2014 at 8:15 am
You need to unpivot your table.
An easy way is to use CROSS APPLY and VALUES clause.
SELECT ParentID
,Child
,NULLIF(ParentID-1, 0) AS ParRel
FROM #TestTable t
CROSS...
April 24, 2014 at 6:29 pm
Remove ",catalog.datfin" from GROUP BY.
If you include it in the group by, you'll getting the minimum value for each date and that will be each date.
April 24, 2014 at 5:43 pm
That code is full of syntax errors. Missing conditions on your JOINs and ON used more than once.
BTW, your subquery might give you an error if more than one year...
April 24, 2014 at 4:22 pm
Have you checked if you have any triggers on finalTbl (I assume that might not be the real name)?
April 24, 2014 at 4:16 pm
You need to include it in your subquery when creating the pivot. Something like this:
from (
select t.Month_date,b.tour_date,m.bus_id,b.[status]
from #bus_master m
LEFT
JOIN #Busdetails b ON m.bus_id = b.bus_id
left outer join #temp t on...
April 24, 2014 at 1:48 pm
Sean Lange (4/24/2014)
Here we created a nonSARGable predicate by casting the column but we also added an implicit conversion because now that our previous integer value has been cast a...
April 24, 2014 at 10:16 am
gbritton1 (4/24/2014)
Another good article here: http://www.techrepublic.com/blog/10-things/10-reasons-to-explicitly-convert-sql-server-data-types
Number 9 and 10 are just wrong. Taking aside that number 9 suggest to make a query non-SARGable to "improve server statistics", both examples rely...
April 24, 2014 at 9:55 am
Viewing 15 posts - 6,541 through 6,555 (of 8,731 total)