Viewing 15 posts - 16 through 30 (of 50 total)
Try this,
SELECT Acc.Account,Fct.ORGANIZATION ,Fct .Year,Period,
CASE WHEN Acc .[SIGN]='Cr' THEN SUM(Fct.AMOUNT ) ELSE 0 END AS Cr,
CASE WHEN Acc.[SIGN]='Dr' THEN SUM(Fct.AMOUNT ) ELSE 0 END AS Dr
FROM #ACCOUNT Acc
INNER...
June 14, 2012 at 11:06 pm
Try this
SELECT level
INTO #myTable
FROM(VALUES('1'),('1.1.3'),('1.2.4.4'),('2'),('3.1'),('10.1'),('10.2'),('11.1'),('11.2'),
('13.1'),('3.2'),('4'),('5'),('6'),('7'),('8'),('8.1'),('9'),('14'))a(level);
;WITH cte
AS
(
SELECT [level], ROW_NUMBER() OVER(
PARTITION BY
SUBSTRING ([level], CASE WHEN CHARINDEX('.',[level],0)=0 THEN 1 ELSE 0 END, CASE WHEN CHARINDEX('.',[level],0)=0 THEN LEN([level]) ELSE CHARINDEX('.',[level],0) END )
ORDER by...
June 14, 2012 at 4:57 am
Use Generate Scripts option in SSMS
June 13, 2012 at 10:23 pm
No effect when you index a nvarchar column. Bigint has no problem
June 13, 2012 at 5:15 am
Try this
;with cte
as
(
select *, row_number() over(partition by [Key],[Year] order by [month]) as ID
from #sale
)
select cte.,cte.[month], cte.[year],cte.value, A.Total
from cte
INNER...
June 12, 2012 at 11:30 pm
try this
select SUBSTRING(
substring('\Beverages\Soda Pop\Mountain Dew',2, len('\Beverages\Soda Pop\Mountain Dew')),
(
CHARINDEX('\',
substring('\Beverages\Soda Pop\Mountain Dew',2, len('\Beverages\Soda Pop\Mountain Dew') ))
)
,len('\Beverages\Soda Pop\Mountain Dew') )
June 12, 2012 at 6:26 am
Pls try this
;with Calender
As (
select
DATEADD(DD,
-ROW_NUMBER ()over (order by (select null)),GETDATE() ) as [date]
from sys.columns C
)
select count(Acc.client_no)as countofClients,
cal.WeekStartDate,
Cal.WeekEndDate
FROM #OngoingServices Acc
inner join
(
select [Date] as WeekStartDate , dateadd(DD...
June 11, 2012 at 5:02 am
select A.[Date] as Friday
from
(
select top 200
DATEADD(DD,
-ROW_NUMBER ()over (order by (select null)),
GETDATE()) as [Date]
from sys.columns
)A
where 'Friday'=datename (weekday,[Date])
and month([Date]) in (
select MONTH(dateadd(month,-1, getdate()))
union
select ...
June 10, 2012 at 11:37 pm
Use Default Trace
June 10, 2012 at 10:26 pm
Try this
SELECT CASE WHEN MONTH(DueDate)=5 THEN DueDate END AS DT
FROM [AdventureWorks].[Purchasing].[PurchaseOrderDetail]
where DueDate is not null and Month(DueDate) is not null
June 8, 2012 at 6:19 am
Use computed column and set peristed in ON
May 31, 2012 at 4:56 am
Create the temp table first . Use INSERT query inside the dynamic query
For Ex
ALTER PROCEDURE#SP
AS
BEGIN
CREATE TABLE #Emp(NAme varchar(100), age int)
declare @sql varchar(max);
SET @sql = 'INSERT...
May 29, 2012 at 3:52 am
Viewing 15 posts - 16 through 30 (of 50 total)