Viewing 15 posts - 16 through 30 (of 1,124 total)
Recently, I came across a similar post to which Jeff Moden has provided a WHILE loop based solution which beats the TALLY table solution.
Here is the post:
http://www.sqlservercentral.com/Forums/Topic860321-338-1.aspx
--Ramesh
February 26, 2010 at 4:13 am
See it if the following solution works.
SELECTField1, Field2, Field3,
Amount + ( CASE WHEN Amount > 0 AND PaymentType = 'CASH' THEN TotalVAT ELSE 0 END ) AS Total
FROM TableX
WHEREDate...
--Ramesh
February 26, 2010 at 4:01 am
Go to Books Online (Books online is the documentation/help available with SQL Server), look for DATEDIFF function.
Partial Syntax of the function is:
DATEDIFF( Interval, Date1, Date2 )
--Ramesh
February 26, 2010 at 2:42 am
Here is another way using OUTER APPLY:
Select t.pkId,
COALESCE( t.Col1, t1.Col1 ) AS Col1,
COALESCE( t.Col2, t2.Col2 ) AS Col2,
COALESCE( t.Col3, t3.Col3 ) AS Col3,
COALESCE( t.Col4, t4.Col4 ) AS Col4
from #tblDemo...
--Ramesh
February 25, 2010 at 6:34 am
Here you go...
selecth, ceiling(RN/3.0),
max(case when RN % 3 = 1 then D else NULL end) D1,
...
--Ramesh
February 25, 2010 at 5:27 am
I am not sure that I understand your requirements clearly, can you elaborate more on how you arrived at the final output containing five columns?
--Ramesh
February 25, 2010 at 4:57 am
I am not sure how can one access data fields in custom code but you can pass the data field values as input parameters to functions defined in custom code.
--Ramesh
February 25, 2010 at 4:50 am
vaibhav.tiwari (2/25/2010)
Hi ramesh sir,I am your big fan...
and i know you...
You are working with infoton right...
Vaibhav
I am wondering how you know me, though I don't know you in anyways. ...
--Ramesh
February 25, 2010 at 4:48 am
Convert the existing query to derived table and apply UNPIVOT operator on the columns.
--Ramesh
February 25, 2010 at 3:56 am
Here you go.
; WITH Table1
AS
(
SELECT1 AS Col1, 'A' AS Col2, 'A1' AS Col3 UNION ALL
SELECT2, 'B', 'A2' UNION ALL
SELECT1, 'B', 'A1' UNION ALL
SELECT1, 'C', 'A3' UNION ALL
SELECT3, 'A', 'A4'
)
SELECTT1.Col1, T2.Col2,...
--Ramesh
February 25, 2010 at 3:40 am
Put any one of the query in Execute SQL Task in SSIS.
--Ramesh
February 25, 2010 at 12:22 am
There are many methods in which this can be done using T-SQL.
-- Method 1 (Using LEFT JOIN)
INSERTTABLE_B( COL1, COL2, COL3 )
SELECTA.COL1, A.COL2, A.COL3
FROMTABLE_A A
LEFT JOIN TABLE_B B ON A.KEY_ID =...
--Ramesh
February 24, 2010 at 11:34 pm
The error clearly says what is missing in the query, a GROUP BY clause.
SELECTdbname, datasize, 'Min Date' AS DateAggregate, MIN(dbdate) AS dbdate
FROMdb_size
GROUP BY dbname, datasize
UNION ALL
SELECTdbname, datasize,...
--Ramesh
February 24, 2010 at 12:31 am
Ok, now I get what you wanted to do.
SELECT ( CASE
WHEN M.TERM_ID LIKE '040%' THEN 'A...
--Ramesh
February 10, 2010 at 1:57 am
You have to use both TRANSACTION and STORED PROCEDURES to accomplish the task.
Here is a sample procedure that inserts a value in 2 different tables.
CREATE PROCEDURE dbo.usp_SaveUserValue
(
@UserValue VARCHAR(100)
)
AS
BEGIN
SET...
--Ramesh
February 9, 2010 at 6:50 am
Viewing 15 posts - 16 through 30 (of 1,124 total)