Viewing 15 posts - 691 through 705 (of 1,923 total)
It's fairly a simple problem. Can i (we) see the expected result out of the sample data u posted?
August 26, 2011 at 3:30 pm
Gianluca Sartori (8/26/2011)
WITH Test(TestField) AS (
SELECT 'aaa'
UNION
...
August 26, 2011 at 10:38 am
LutzM (8/26/2011)
@ColdCoffe: are you sure the sample code in this post is related to the original question?Seems like it belongs to "the other thread"... ;-).
Lutz, you are right, this sample...
August 26, 2011 at 9:37 am
LutzM (8/26/2011)
SELECT TOP 1 ID,
Name,
Number,
...
August 26, 2011 at 1:45 am
I see this is your first ever post here, Kavitha, so Welcome to SSC!!
Now, we could not gather much information from your question. Can you please brief us about what...
August 26, 2011 at 1:42 am
LutzM (8/26/2011)
Assuming, a row can be identified, the following might work:
Oh Mr.Lutz :w00t: i posted a code which was fairly similar to yours 🙂 i was tempted to solve...
August 26, 2011 at 1:36 am
How about this?
DECLARE @FirstTable TABLE
(
Name VARCHAR(10)
,id INT
,value ...
August 26, 2011 at 1:32 am
Something like this?
declare @String VARCHAR(15)= '12345676'
select @String = STUFF(STUFF(@String,4,0,'-') ,9,0,'-')
select @String
August 26, 2011 at 12:51 am
You can make use of STUFF !
Is the dashes needed at the 4th and 8th places always ?
August 26, 2011 at 12:47 am
I actually quite dint understand your requirement. Can you be more specific? You have been terrific in providing sample table and data, a little more explanation could get me working...
August 26, 2011 at 12:26 am
Dynamic query, may be ???
August 25, 2011 at 9:21 pm
You're welcome.
This is method 2, using Cross Apply and Distinct 🙂
;with cte ( Account ,ICP ,Custom1,Custom2) AS
(
SELECT 'AC_12345','ICP2','Cust1gftr','Cust2abcd'
UNION ALL SELECT 'AC_12345','ICP3','Custppoe','Cust2efgh'
UNION ALL SELECT 'AC_12345','ICP1','Cust1uytr','Cust2abcd'
UNION ALL SELECT 'AC_54321','ICP3','Cust1cvbc','Cust2asas'
UNION ALL...
August 25, 2011 at 3:04 pm
One method is to use Row_number to get that
;with cte ( Account ,ICP ,Custom1,Custom2) AS
(
SELECT 'AC_12345','ICP2','Cust1gftr','Cust2abcd'
UNION ALL SELECT 'AC_12345','ICP3','Custppoe','Cust2efgh'
UNION ALL SELECT 'AC_12345','ICP1','Cust1uytr','Cust2abcd'
UNION ALL SELECT 'AC_54321','ICP3','Cust1cvbc','Cust2asas'
UNION ALL SELECT 'AC_54321','ICP5','Cust1fghr','Cust2qwas'
UNION...
August 25, 2011 at 2:43 pm
OH my bad, i am sorry being a hasty poster. I should have taken time to atleast parse the code, sorry!
Here is the syntax-error-free code; Whether is works for you,...
August 25, 2011 at 10:08 am
You dont need a cursor to do this 🙂
some like
DECLARE @MaxIDVal BIGINT
SELECT @MaxIDVal = TOP 1(AcctID) FROM dbo.tableA ORDER BY AcctID DESC
; WITH CTE AS
(
SELECT RN = ROW_NUMBER()...
August 24, 2011 at 2:56 pm
Viewing 15 posts - 691 through 705 (of 1,923 total)