Viewing 15 posts - 211 through 225 (of 368 total)
Manole,
your question is very good.
Procedure is created "with execute as caller".
When we call the procedure with a user that has no rights on underlying objects (objects that procedure uses),
it would...
June 9, 2012 at 4:08 pm
SELECT COUNT(DISTINCT ClientName) AS NoClients, COUNT(desc) AS NumMtrInv, desc, SUM(sales) AS Fees, AVG(Fee) AS Avgsales,
SUM(sales) / COUNT(DISTINCT ClientName) AS AvgSalesPerClient
FROM dbo.VW_sales
GROUP BY desc
ORDER BY COUNT(DISTINCT NoName), Desc
April 20, 2012 at 2:21 am
Thanks Stewart, you are right. I don't know from where I concluded cte is not for view. Maybe sometime ago I tried that and it didn't worked, but don't know...
April 20, 2012 at 2:18 am
GilaMonster (4/19/2012)
The clustered index key (which is the specified columns + uniquifier) is then used as the 'pointer' in any nonclustered index.
Exactly. That's what I tried to explain. Not just...
April 19, 2012 at 11:42 pm
Yes, but CTE bring limitations: it wont work in a view, and it works on less SQL versions that without CTE. So, my choice is to use a technique when...
April 19, 2012 at 11:39 pm
GilaMonster (4/19/2012)
Not the primary key. In the case of a nonclustered index on a table with a clustered index, the 'pointer' is the clustered index key
Dear Gilla, I tried to...
April 19, 2012 at 5:13 pm
RAISERROR with NOWAIT is also nice because you can build a message inline (using placeholders %d, %s, etc):
RAISERROR (' now is executing step %d...' ,10,1, @step_number) WITH NOWAIT
Add optional parameter...
April 19, 2012 at 5:03 pm
CTE is good solution for recursions and if you need same expression more than once, but this is not the case here.
So, the same thing without CTE:
SELECT it.*
FROM
(SELECT items.*,
rn =...
April 19, 2012 at 4:50 pm
You need to read some good literature about indexes. It's difficult to put it in few sentences, but I'll try.
Every index consumes space and it has nothing to do with...
April 19, 2012 at 4:37 pm
You did not provide a script to create a table with sample data, so it makes much harder to answer your question.
Your example looks like you need a column with...
April 19, 2012 at 4:01 pm
SELECT o.orderno,
Descr1_PriceSum = SUM(CASE WHEN o.Descr=1 THEN o.Price ELSE 0 END),
Descr2_PriceSum = SUM(CASE WHEN o.Descr=2 THEN o.Price ELSE 0 END)
from dbo.orders o
group by o.orderno
ordernoDescr1_PriceSumDescr2_PriceSum
1100,000,00
2142,000,00
388,000,00
40,00244,00
If you want Descr to be...
April 19, 2012 at 1:07 am
No, unfortunately you cannot call sp from a function. There are also other limitations (no PRINT, RAISERROR, no try-catch, temp tables not visible, no changing of db tables allowed etc).
But,...
April 18, 2012 at 9:00 am
Simplest form:
select Decade = convert(VARCHAR(9), s.s_date, 120), Amount = sum(s.amount)
from dbo.sample s
group by convert(VARCHAR(9), s.s_date, 120) -- 120 = yyyy-mm-dd hh:mi:ss
You could use variation, e.g. month + decade, fill empty...
April 18, 2012 at 8:46 am
Execute your query without GROUP BY to see the values it actually sums.
Probably you have bad join condition as Dwain wrote.
April 18, 2012 at 8:25 am
Viewing 15 posts - 211 through 225 (of 368 total)