I have found a bug in when using hide duplicates. It only affects certain renderers.
I have field with hide duplicates set on it.
In Preview or Deployed view, The value is shown in the first row correctly and not in subsequent rows until it changes as you would expect.
When in Print Preview in VS or Exported to PDF, it isn't shown in the first row.
Example;
--
Sales 123 456
789 123
432 123
Costs 111 222
333 444
When exported to PDF
--
123 456
789 123
432 123
Costs 111 222
333 444
Regards
Chris McGuiganThank you for your input.
I will investigate this issue.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
news:E613FB90-D604-48E1-AFD9-8B35EED99A96@.microsoft.com...
> To narrow this down further, the first line in the problem section was
> conditionally hidden.
> If I made the first line of the second section hidden, the problem moves
> to that section.
> Regards
> Chris McGuigan
> "Chris McGuigan" wrote:
>> I have found a bug in when using hide duplicates. It only affects certain
>> renderers.
>> I have field with hide duplicates set on it.
>> In Preview or Deployed view, The value is shown in the first row
>> correctly and not in subsequent rows until it changes as you would
>> expect.
>> When in Print Preview in VS or Exported to PDF, it isn't shown in the
>> first row.
>> Example;
>> --
>> Sales 123 456
>> 789 123
>> 432 123
>> Costs 111 222
>> 333 444
>> When exported to PDF
>> --
>> 123 456
>> 789 123
>> 432 123
>> Costs 111 222
>> 333 444
>> Regards
>> Chris McGuigan|||Could you email me your RDL, because I'm unable to reproduce this problem.
Thank you,
Lev
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Chris McGuigan" <ChrisMcGuigan@.discussions.microsoft.com> wrote in message
news:E613FB90-D604-48E1-AFD9-8B35EED99A96@.microsoft.com...
> To narrow this down further, the first line in the problem section was
> conditionally hidden.
> If I made the first line of the second section hidden, the problem moves
> to that section.
> Regards
> Chris McGuigan
> "Chris McGuigan" wrote:
>> I have found a bug in when using hide duplicates. It only affects certain
>> renderers.
>> I have field with hide duplicates set on it.
>> In Preview or Deployed view, The value is shown in the first row
>> correctly and not in subsequent rows until it changes as you would
>> expect.
>> When in Print Preview in VS or Exported to PDF, it isn't shown in the
>> first row.
>> Example;
>> --
>> Sales 123 456
>> 789 123
>> 432 123
>> Costs 111 222
>> 333 444
>> When exported to PDF
>> --
>> 123 456
>> 789 123
>> 432 123
>> Costs 111 222
>> 333 444
>> Regards
>> Chris McGuigan
Showing posts with label duplicates. Show all posts
Showing posts with label duplicates. Show all posts
Thursday, March 22, 2012
Tuesday, February 14, 2012
Breaking a row of data into multiple CSV rows
Does anyone have a routine that takes a row of data from database, duplicates/triplicates it, appends some information to it and writes it out as 2/3 CSV rows.
Basically I need to do the following.
Selected from database:
Row1 Col1 Col2 Col3
Output:
Row1 Col1, Col2, Col3, abc
Row1 Col1, Col2, Col3, def
Row1 Col1, Col2, Col3, ghi
Thank youThis might help with part of it:
SELECT '"' + Row1 + '","' + Col1 + '","' + Col2 + '","' + Col3 + + '";'|||You could do a SELECT INTO 3 times for each "row" in the original table. It would be like:
SELECT INTO newtable
Col1, Col2, Col3, 'abc' AS Col4
FROM oldtable
WHERE Row=1
SELECT INTO newtable
Col1, Col2, Col3, 'def' AS Col4
FROM oldtable
WHERE Row=1
SELECT INTO newtable
Col1, Col2, Col3, 'ghi' AS Col4
FROM oldtable
WHERE Row=1
Then you would convert newtable to CSV afterward (with BCP maybe).
That's assuming there is a column named Row with a value of 1. But if you have a key column ( a field with unique values), the new table can't use that as a key column because you'll be making three copies of each row.
But since your example wasn't very specific, either is the answer.
Another method is to use a cursor and process each row.|||I think using the cursor would be a better option since the number of rows that i need to "break" are in thousands.
I am just not sure how to use cursor.|||Have a look in BOL (Books online) to see how cursors, but be warned that cursors can be inefficient, particularly with a 'large' number of rows - some people on this forum positively detest them!
Think about using temporary tables/table variables instead.
Lempster|||Funny you should ask
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[udf_CSVTable]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[udf_CSVTable]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE FUNCTION udf_CSVTable(@.Str varchar(7000))
RETURNS @.t table (numberval int, stringval varchar(100), DateVal datetime)
AS
BEGIN
DECLARE @.i int, @.c varchar(100)
SELECT @.Str = @.Str + ',', @.i = 1, @.c = ''
WHILE @.i <= len(@.Str)
BEGIN
IF substring(@.Str,@.i,1) = ','
BEGIN
INSERT INTO @.t(numberval, stringval, DateVal)
VALUES ( CASE WHEN isnumeric(@.c)=1 THEN @.c else Null END
, rtrim(ltrim(@.c))
, CASE WHEN isdate(@.c)=1 then @.c else Null END)
SET @.c = ''
END
ELSE
SET @.c = @.c + SUBSTRING(@.Str,@.i,1)
SET @.i = @.i +1
END
RETURN
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Basically I need to do the following.
Selected from database:
Row1 Col1 Col2 Col3
Output:
Row1 Col1, Col2, Col3, abc
Row1 Col1, Col2, Col3, def
Row1 Col1, Col2, Col3, ghi
Thank youThis might help with part of it:
SELECT '"' + Row1 + '","' + Col1 + '","' + Col2 + '","' + Col3 + + '";'|||You could do a SELECT INTO 3 times for each "row" in the original table. It would be like:
SELECT INTO newtable
Col1, Col2, Col3, 'abc' AS Col4
FROM oldtable
WHERE Row=1
SELECT INTO newtable
Col1, Col2, Col3, 'def' AS Col4
FROM oldtable
WHERE Row=1
SELECT INTO newtable
Col1, Col2, Col3, 'ghi' AS Col4
FROM oldtable
WHERE Row=1
Then you would convert newtable to CSV afterward (with BCP maybe).
That's assuming there is a column named Row with a value of 1. But if you have a key column ( a field with unique values), the new table can't use that as a key column because you'll be making three copies of each row.
But since your example wasn't very specific, either is the answer.
Another method is to use a cursor and process each row.|||I think using the cursor would be a better option since the number of rows that i need to "break" are in thousands.
I am just not sure how to use cursor.|||Have a look in BOL (Books online) to see how cursors, but be warned that cursors can be inefficient, particularly with a 'large' number of rows - some people on this forum positively detest them!
Think about using temporary tables/table variables instead.
Lempster|||Funny you should ask
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[udf_CSVTable]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[udf_CSVTable]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE FUNCTION udf_CSVTable(@.Str varchar(7000))
RETURNS @.t table (numberval int, stringval varchar(100), DateVal datetime)
AS
BEGIN
DECLARE @.i int, @.c varchar(100)
SELECT @.Str = @.Str + ',', @.i = 1, @.c = ''
WHILE @.i <= len(@.Str)
BEGIN
IF substring(@.Str,@.i,1) = ','
BEGIN
INSERT INTO @.t(numberval, stringval, DateVal)
VALUES ( CASE WHEN isnumeric(@.c)=1 THEN @.c else Null END
, rtrim(ltrim(@.c))
, CASE WHEN isdate(@.c)=1 then @.c else Null END)
SET @.c = ''
END
ELSE
SET @.c = @.c + SUBSTRING(@.Str,@.i,1)
SET @.i = @.i +1
END
RETURN
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Subscribe to:
Posts (Atom)