Wednesday, March 28, 2012
How to show rows of dataset as columns in report
I have a dataset whose rows need to shown as columns of a table in report.
Is it possible to do so?
Please help
regards,
SachinCan you use a matrix instead of a table?
"Sachin Laddha" <SachinLaddha@.discussions.microsoft.com> wrote in message
news:5E1EAF65-33C1-4D19-B230-D4826ACA3BA7@.microsoft.com...
> Hi,
> I have a dataset whose rows need to shown as columns of a table in report.
> Is it possible to do so?
> Please help
> regards,
> Sachin|||Hi,
I am quite new to reporting services.
Wll matrix solve my problem?
Please help.
regards,
Sachin.
"Steve MunLeeuw" wrote:
> Can you use a matrix instead of a table?
> "Sachin Laddha" <SachinLaddha@.discussions.microsoft.com> wrote in message
> news:5E1EAF65-33C1-4D19-B230-D4826ACA3BA7@.microsoft.com...
> > Hi,
> >
> > I have a dataset whose rows need to shown as columns of a table in report.
> > Is it possible to do so?
> >
> > Please help
> > regards,
> > Sachin
>
>|||I think that it will. The Adventure Works Sample Reports that ships with
SSRS 2005 has a Company Sales report that demonstrates the use of the
matrix. It has Order Year and Order Qtr as columns across the top.
"Sachin Laddha" <SachinLaddha@.discussions.microsoft.com> wrote in message
news:334F642D-F816-46FD-BBF4-7F8D1E0B8276@.microsoft.com...
> Hi,
> I am quite new to reporting services.
> Wll matrix solve my problem?
> Please help.
> regards,
> Sachin.
>
> "Steve MunLeeuw" wrote:
>> Can you use a matrix instead of a table?
>> "Sachin Laddha" <SachinLaddha@.discussions.microsoft.com> wrote in message
>> news:5E1EAF65-33C1-4D19-B230-D4826ACA3BA7@.microsoft.com...
>> > Hi,
>> >
>> > I have a dataset whose rows need to shown as columns of a table in
>> > report.
>> > Is it possible to do so?
>> >
>> > Please help
>> > regards,
>> > Sachin
>>sql
How to show empty rows in crystal report when data reaches to EOF
Otherwise post some sample data and the format you want
How to show duplicates in reports
I'm trying to create a report in Sql Server 2005 Reporting Services where it will display duplicates rows in the reports. I'm unable to find the property that enables this. I would need something like HideDuplicates = false, but that is not the way it is intended to be used. If HideDuplicates is left blank, it seems to still hide duplicate values if the preceding row matches.
The report is a crosstab type, so we are using a Matrix for the report item. I'll illustrate with a simple example:
This is what we currently get:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
B | Item 2 | |
Item 3 | ||
Type 2 | A | Item 4 |
B | Item 5 |
This is what we want:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
Type 1 | B | Item 2 |
Type 1 | B | Item 3 |
Type 2 | A | Item 4 |
Type 2 | B | Item 5 |
I'm sure its something simple, but we just cant seem to find the solution,
Thanks
Darin
Rather than using a matrix report, I think a simple list report would do what you are looking for (if you don't do any grouping). You can still use aggreated fields in the simple list report.
|||Unfortunately we need to use a matrix as the actual report is a crosstab, I just didn't illustrate that in the example for simplicity sake.
I think the report looks nicer with the blanks and is easier to read; however, if it is dumped to Excel for further analysis ( which in our actual report will happen often), the auto filter function will not work as the blank rows are not included if a specifiec catagory is selected. Only the first row that is allgned with the merged cells is shown.
|||Open the code view of the report and search for the XML node called "HideDuplicates". See http://msdn2.microsoft.com/en-us/library/ms152916.aspx for on how to set. Removing the element entirely will cause the values to appear in each row on the report, like you'd want to have for use in Excel.
My problem is related. I have business analysts using the Report Builder tool basically as a querying tool. 90% of the time, they export to Excel and then crunch there. While I know this is not intended usage of Reporting Services, I am still disappointed by the fact that, in order to get duplicates to appear, you must go code-side, something I can't push off on a BA.
Any ideas for editting a Report Builder generated report file on the fly, to remove "HideDuplicates" elements?
|||Try setting the "HideDuplicate" property on the "Type 1" textbox in your report.
Here are the defintion of the Textbox properties:
=========================================
Textbox
The Textbox element has the following attributes/elements in addition to what it inherits from ReportItem:
Attributes/Elements
Name
Card
Type
Description
Value
1
Expression
(Variant)
An expression, the value of which is displayed in the text-box.
This can be a constant expression for constant labels.
CanGrow
0-1
Boolean
Indicates the Textbox size can increase to accommodate the contents
CanShrink
0-1
Boolean
Indicates the Textbox size can decrease to match the contents
HideDuplicates
0-1
String
Indicates the text should not be displayed when the value of the expression associated with the report item is the same as the preceding instance.The value of HideDuplicates is the name of a containing grouping (other than the current grouping) or data set over which to apply the hiding.Each time a new instance of that group is encountered, the first instance of this report item will not be hidden. Rows on a previous page are ignored for the purposes of hiding duplicates.If the textbox is in a table or matrix cell, only the text will be omitted.The textbox will remain to provide background and border for the cell.Outside of a table/matrix cell, the background and borders are omitted as well.
Ignored in matrix subtotals.
ToggleImage
0-1
Element
Indicates the initial state of a toggling image should one be displayed as a part of the textbox.
UserSort
0-1
Element
Indicates an end-user sort control should be displayed as a part of this textbox in the UI.
DataElementStyle
0-1
Enum
Indicates whether textbox value should render as an element or attribute: Auto (Default) | AttributeNormal | ElementNormal. Auto uses the setting on the Report element.
Regards
How to show duplicates in reports
I'm trying to create a report in Sql Server 2005 Reporting Services where it will display duplicates rows in the reports. I'm unable to find the property that enables this. I would need something like HideDuplicates = false, but that is not the way it is intended to be used. If HideDuplicates is left blank, it seems to still hide duplicate values if the preceding row matches.
The report is a crosstab type, so we are using a Matrix for the report item. I'll illustrate with a simple example:
This is what we currently get:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
B | Item 2 | |
Item 3 | ||
Type 2 | A | Item 4 |
B | Item 5 |
This is what we want:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
Type 1 | B | Item 2 |
Type 1 | B | Item 3 |
Type 2 | A | Item 4 |
Type 2 | B | Item 5 |
I'm sure its something simple, but we just cant seem to find the solution,
Thanks
Darin
Rather than using a matrix report, I think a simple list report would do what you are looking for (if you don't do any grouping). You can still use aggreated fields in the simple list report.
|||Unfortunately we need to use a matrix as the actual report is a crosstab, I just didn't illustrate that in the example for simplicity sake.
I think the report looks nicer with the blanks and is easier to read; however, if it is dumped to Excel for further analysis ( which in our actual report will happen often), the auto filter function will not work as the blank rows are not included if a specifiec catagory is selected. Only the first row that is allgned with the merged cells is shown.
|||Open the code view of the report and search for the XML node called "HideDuplicates". See http://msdn2.microsoft.com/en-us/library/ms152916.aspx for on how to set. Removing the element entirely will cause the values to appear in each row on the report, like you'd want to have for use in Excel.
My problem is related. I have business analysts using the Report Builder tool basically as a querying tool. 90% of the time, they export to Excel and then crunch there. While I know this is not intended usage of Reporting Services, I am still disappointed by the fact that, in order to get duplicates to appear, you must go code-side, something I can't push off on a BA.
Any ideas for editting a Report Builder generated report file on the fly, to remove "HideDuplicates" elements?
|||Try setting the "HideDuplicate" property on the "Type 1" textbox in your report.
Here are the defintion of the Textbox properties:
=========================================
Textbox
The Textbox element has the following attributes/elements in addition to what it inherits from ReportItem:
Attributes/Elements
Name
Card
Type
Description
Value
1
Expression
(Variant)
An expression, the value of which is displayed in the text-box.
This can be a constant expression for constant labels.
CanGrow
0-1
Boolean
Indicates the Textbox size can increase to accommodate the contents
CanShrink
0-1
Boolean
Indicates the Textbox size can decrease to match the contents
HideDuplicates
0-1
String
Indicates the text should not be displayed when the value of the expression associated with the report item is the same as the preceding instance.The value of HideDuplicates is the name of a containing grouping (other than the current grouping) or data set over which to apply the hiding.Each time a new instance of that group is encountered, the first instance of this report item will not be hidden. Rows on a previous page are ignored for the purposes of hiding duplicates.If the textbox is in a table or matrix cell, only the text will be omitted.The textbox will remain to provide background and border for the cell.Outside of a table/matrix cell, the background and borders are omitted as well.
Ignored in matrix subtotals.
ToggleImage
0-1
Element
Indicates the initial state of a toggling image should one be displayed as a part of the textbox.
UserSort
0-1
Element
Indicates an end-user sort control should be displayed as a part of this textbox in the UI.
DataElementStyle
0-1
Enum
Indicates whether textbox value should render as an element or attribute: Auto (Default) | AttributeNormal | ElementNormal. Auto uses the setting on the Report element.
How to show duplicates in reports
I'm trying to create a report in Sql Server 2005 Reporting Services where it will display duplicates rows in the reports. I'm unable to find the property that enables this. I would need something like HideDuplicates = false, but that is not the way it is intended to be used. If HideDuplicates is left blank, it seems to still hide duplicate values if the preceding row matches.
The report is a crosstab type, so we are using a Matrix for the report item. I'll illustrate with a simple example:
This is what we currently get:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
B | Item 2 | |
Item 3 | ||
Type 2 | A | Item 4 |
B | Item 5 |
This is what we want:
Catagory | Class | Detail |
Type 1 | A | Item 1 |
Type 1 | B | Item 2 |
Type 1 | B | Item 3 |
Type 2 | A | Item 4 |
Type 2 | B | Item 5 |
I'm sure its something simple, but we just cant seem to find the solution,
Thanks
Darin
Rather than using a matrix report, I think a simple list report would do what you are looking for (if you don't do any grouping). You can still use aggreated fields in the simple list report.
|||Unfortunately we need to use a matrix as the actual report is a crosstab, I just didn't illustrate that in the example for simplicity sake.
I think the report looks nicer with the blanks and is easier to read; however, if it is dumped to Excel for further analysis ( which in our actual report will happen often), the auto filter function will not work as the blank rows are not included if a specifiec catagory is selected. Only the first row that is allgned with the merged cells is shown.
|||Open the code view of the report and search for the XML node called "HideDuplicates". See http://msdn2.microsoft.com/en-us/library/ms152916.aspx for on how to set. Removing the element entirely will cause the values to appear in each row on the report, like you'd want to have for use in Excel.
My problem is related. I have business analysts using the Report Builder tool basically as a querying tool. 90% of the time, they export to Excel and then crunch there. While I know this is not intended usage of Reporting Services, I am still disappointed by the fact that, in order to get duplicates to appear, you must go code-side, something I can't push off on a BA.
Any ideas for editting a Report Builder generated report file on the fly, to remove "HideDuplicates" elements?
|||Try setting the "HideDuplicate" property on the "Type 1" textbox in your report.
Here are the defintion of the Textbox properties:
=========================================
Textbox
The Textbox element has the following attributes/elements in addition to what it inherits from ReportItem:
Attributes/Elements
Name
Card
Type
Description
Value
1
Expression
(Variant)
An expression, the value of which is displayed in the text-box.
This can be a constant expression for constant labels.
CanGrow
0-1
Boolean
Indicates the Textbox size can increase to accommodate the contents
CanShrink
0-1
Boolean
Indicates the Textbox size can decrease to match the contents
HideDuplicates
0-1
String
Indicates the text should not be displayed when the value of the expression associated with the report item is the same as the preceding instance.The value of HideDuplicates is the name of a containing grouping (other than the current grouping) or data set over which to apply the hiding.Each time a new instance of that group is encountered, the first instance of this report item will not be hidden. Rows on a previous page are ignored for the purposes of hiding duplicates.If the textbox is in a table or matrix cell, only the text will be omitted.The textbox will remain to provide background and border for the cell.Outside of a table/matrix cell, the background and borders are omitted as well.
Ignored in matrix subtotals.
ToggleImage
0-1
Element
Indicates the initial state of a toggling image should one be displayed as a part of the textbox.
UserSort
0-1
Element
Indicates an end-user sort control should be displayed as a part of this textbox in the UI.
DataElementStyle
0-1
Enum
Indicates whether textbox value should render as an element or attribute: Auto (Default) | AttributeNormal | ElementNormal. Auto uses the setting on the Report element.
How to show duplicate rows in Report Builder ?
I've created a report in Report Builder, based on a query. When I run the report in Report Builder, it doesn't show the duplicates rows, even if it works fine in Data source view.
How can I see al rows in Report Builder(even if they're duplicates) ?
Thank you in advance.
Best regards,
VV
Report Builder shows groups of data, if the data you gropued does not contain a unique column, the data will be grouped, if you want to display all rows, you will need to display column which is different in the mutli-instanced rows.
Jens K. Suessmeyer.
http://www.sqlserver2005.de
How to show distinct rows of the column of the dataset and number of distinct rows of that colum
suppose i have aDataset with 11 rows. field1 with 5 rows of aaa, 6 rows of "bbb"
I want's some thing like
field1 rowcount
aaa 5
bbb 6
Have a table and map it to the dataset. Insert a group (say table_Group1) to the table with the grouping column being "Fields!field1.Value". In the group header row of your table, use Fields!field1.Value and CountDistinct(FIelds!field1.Value, "table_Group1") to get your desired values.
Pls mark the post as answered if your problem is solved.
Shyam
Monday, March 26, 2012
How to show all tables info in Task Pad?
1. Does anyone know how I can see this info in Task Pad for all tables, without having to use the search function and look up 200+ tables one-by-one?
2. Does anyone know of another utility or statement to run against the DB which will return this info all at once for all the tables?
Thanks.Task pad should show Next and Last options in the bottom of the page.
You can also get all user table info by executing this sql..
select * from information_schema.tables where table_type like 'BASE TABLE'|||First, in TaskPad, there is no next or last button, second that line of code you gave:
select * from information_schema.tables where table_type like 'BASE TABLE'
Did not return the # of rows and KB size of all of my tables.
THis is what I am looking for.
Anyone else know?
I ran the "SP_help" and "SP_tables" stored procedures, but they don't return the table row count or size.|||I'd suggest:SELECT CAST(Coalesce(Sum(si.reserved) / 128.0, 0) AS DECIMAL(5, 2)) AS total_mb
, CAST(Coalesce(Sum(CASE WHEN si.indid IN (0, 1) THEN si.reserved END)
/ 128.0, 0) AS DECIMAL(5, 2)) AS data_mb
, CAST(Coalesce(Sum(CASE WHEN si.indid = 255 THEN si.reserved END)
/ 128.0, 0) AS DECIMAL(5, 2)) AS blob_mb
, CAST(Coalesce(Sum(CASE WHEN si.indid NOT IN (0, 1, 255) THEN
si.reserved END) / 128.0, 0) AS DECIMAL(5, 2)) AS index_mb
, Object_Name(si.id)
FROM dbo.sysindexes AS si
GROUP BY si.id-PatP|||Pat,
What does that code do. Here was my output:
(20 row(s) affected)
Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
Warning: Null value is eliminated by an aggregate or other SET operation.|||sp_spaceused?
EDIT: Found this...
USE Northwind
GO
SET NOCOUNT ON
GO
CREATE TABLE #SpaceUsed (
[name] varchar(255)
, [rows] varchar(25)
, [reserved] varchar(25)
, [data] varchar(25)
, [index_size] varchar(25)
, [unused] varchar(25)
)
GO
DECLARE @.tablename nvarchar(128)
, @.maxtablename nvarchar(128)
, @.cmd nvarchar(1000)
SELECT @.tablename = ''
, @.maxtablename = MAX(name)
FROM sysobjects
WHERE xtype='u'
WHILE @.tablename < @.maxtablename
BEGIN
SELECT @.tablename = MIN(name)
FROM sysobjects
WHERE xtype='u' and name > @.tablename
SET @.cmd='exec sp_spaceused['+@.tablename+']'
INSERT INTO #SpaceUsed EXEC sp_executesql @.cmd
END
SET NOCOUNT OFF
GO
SELECT * FROM #SpaceUsed
GO
DROP TABLE #SpaceUSed
GO|||Pat,
What does that code do. Here was my output:
(20 row(s) affected)
Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
Warning: Null value is eliminated by an aggregate or other SET operation.Change the 5s to 15s and try again.
It shows some interesting space observations, by table.
-PatP|||pat,
That returned data, but the data_mb figures seem to be close to half of the actual size. For example, the size of a table from TaskPad is 79656 KB and your query generates 38.94 MB.
Is this what is expected? Is the data_mb column the table size?
Thanks for the help, it is greatly appreciated.|||Brett,
Wonderful!!!!!!!!!!
That was it!!!!!!
Thanks a million!!!!!!|||Does my total match the taskpad total?
-PatP
How to share read only data
Hi,
I'm new to replication. Can anyone help with the following?
I want to publish the specific rows of data that are created on the publisher without accepting changes to those rows from subscribers, but do accept new rows (and changes to those rows) from subscribers.
EG. publisher creates rows 1 and 2 which are published to the subscriber
subscriber creates rows 3 and 4 which are merged back to the publisher
subscriber's updates (or delets) to rows 1 and 2 are not merged back to the publisher
So basically I want the publisher created rows to be published but remain as is whilst allowing subscriber created rows to be merged back to the publisher.
Hope is makes sense.
Thanks in advance,
Seedsy
Look at the properties of the articles (tables). There is an option called Synchronization Direction. That property, along with others, are what you are looking for.
By default, the Synchronization Direction property is set to Bidirectional, meaning, data will be synchronized both directions. I am pretty sure you can set this property to only allow synchronization one direction.
Hope this helps...
|||I couldn't find any properties within the Publication's Articles' "Table Article Properties" but I found the SQLMergeObject's ExchangeType Property which allows upload / download / bidirectional. Shame its not a GUI option within the REPL tools.
Thanks I should be able to work it out from here.
|||Basically you want to publish ins/upd/del changes from the publisher to the subscriber, and only inserts at the subscriber to the publisher, correct? Seems like you want to implement bi-directional transactional replication (or possibly peer to peer replication), you can decide not to replicate upd and del commands at one of the nodes in the article properties.|||Thanks Greg.
I can see that Table Article properties allows checking of the user permissions when merging subscriber changes for Insert, Update and Delete.
So is the approach that ... one should be using the restrictions of user permissions to disallow update and delete by the subscriber?
Seedsy
PS I should mention I'm using SQL2000 (V8.00.2039) SP4 so maybe I don't have all the bells and whistles.
|||i'm not sure it will work for merge replication, but I'm sure bi-directional transactional replication is what you need if you're on SQL 2000.Monday, March 12, 2012
How to set the database to always use next increment number?
Is there a way to make the primary ID as Identity Column to always be in order? For example, I have 5 rows with ID 1,2,3,4,5. If I delete record number 5 and then added another record, the ID shows up as 6 and not 5. Or if I delete record number 3, the next ID is going to be 6 instead of 3. I like to keep all my ID in order if possible and not skipping if that is even possible or should I use that practice.
I think its good way if ID is incrementing by this you can come to know which record inserted when and so on ....
A good article on identity
http://msdn2.microsoft.com/en-us/library/ms971502.aspx
|||
it is possible but you have to do it yourself by switching identity insert ON and OFF in your code and taking care about inserted value. It is not recommended way because it slow down insert process and also it can destroy your related record information if you have any, If you would like to have records order information for some purposes you can always do select statement like:
select identity(int,1,1) new_ID, old_idinto #test
from yourtablename
select * from #test
order by new_ID
and next select by new_ID your result.
You can also use ROW_NUMBER:
select ROW_NUMBER() OVER(ORDER BY old_id ASC) [OrderNo] from from yourtablename
Many thanks for all your responses. The reason I was thinking about doing that is because this table is for linking pages. These links will be added and deleted often..and if there is no way to keep the ID in order, I'm afraid the ID may get too big but with less than 40 or 50 actual records in the table.
|||There is no inbuilt solution for your problem.. you need to use alternative methods..
2 of those methods are discusses here.
http://www.sqlteam.com/item.asp?ItemID=765
|||
Many thanks for the link. It looks like I could use this:
declare @.intCounter int
set @.intCounter = 0
update Yaks
SET @.intCounter = YakSequenceNumber = @.intCounter + 1
The question I have is, do I run the above code everytime when I want to update and insert? Or do I run this code at the begingin where there is no record yet in the table?
|||I think you need to use this while you are inserting. Is this make sense
Okay, so can you give me a sample code of how I would use this while inserting in C# code behind? I'm still unclear as to how I would use it. By the way, if I'm using this, do I turn of the column Identity?
|||I will create one example for you can give it to you
|||This one solution has one big disadvantage that it will slow down your insert so maybe you should run this one time a day(or hour) for your table instead of running it on every insert?
But solution is very nice
Friday, March 9, 2012
How to set No of rows per page in ssrs
Hi All,
By default in ssrs there are some fixed records..per page.......i mean each page contains (n) no of records.........per page..........?I want to display 100 records per page...for this what can i do ..please suggest .......
Thank's in Advance....
Hi
Add group with the following expression = Ceiling(RonNumber(Nothing)/N). Here N is the No of records in per page. And Select the Check box "Page Break either after/before"
Thanks
Wednesday, March 7, 2012
How to set limit in SSIS
Hi,
I am trying to import some 35-40 flat files into my SQL Database, however I don't want to imort all the data from each file, but just top 20 rows only for data quality check. Flat files are very huge so I don't want to import all of the data into my database.
Thanks,
gpat
gvphubli wrote:
Hi,
I am trying to import some 35-40 flat files into my SQL Database, however I don't want to imort all the data from each file, but just top 20 rows only for data quality check. Flat files are very huge so I don't want to import all of the data into my database.
Thanks,
gpat
Does this help?
Select Top N in a data-flow
(http://blogs.conchango.com/jamiethomson/archive/2005/07/27/SSIS-Nugget_3A00_-Select-Top-N-in-a-data_2D00_flow.aspx)
-Jamie
Friday, February 24, 2012
How To Set a Variable During an Insert Into Select From
I'm inserting rows into a table that I retrieve from another table.
There's a lot of data manipulation going on during this process.
For 10 columns in the Select From portion I'm using a CASE statement that
starts with CASE
WHEN Left(Discount_Specification, 2)= @.PF THEN etc.
END,
Instead of doing the "Left" 10 times (10 * 8 million rows in the "From"
table!) I though of setting a variable: Set @.MyVar =
Left(Discount_Specification, 2) and then
saying WHEN @.MyVar = @.PF etc.
I just don't know where in the logic to place this Set @.MyVar so it works
for each row that's inserted.
TIA,
RitaHard to say without DDL, but perhaps something like:
INSERT INTO ...
SELECT ds, ds + 'a', col2
FROM
(
SELECT LEFT(Discout_Specification, 2) AS ds, col2 FROM tbl
) AS t
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"RitaG" <RitaG@.discussions.microsoft.com> wrote in message
news:A07835AD-AAC2-4225-BA8C-FDA70C1C0631@.microsoft.com...
> Hello.
> I'm inserting rows into a table that I retrieve from another table.
> There's a lot of data manipulation going on during this process.
> For 10 columns in the Select From portion I'm using a CASE statement that
> starts with CASE
> WHEN Left(Discount_Specification, 2)= @.PF THEN etc.
> END,
> Instead of doing the "Left" 10 times (10 * 8 million rows in the "From"
> table!) I though of setting a variable: Set @.MyVar =
> Left(Discount_Specification, 2) and then
> saying WHEN @.MyVar = @.PF etc.
> I just don't know where in the logic to place this Set @.MyVar so it works
> for each row that's inserted.
> TIA,
> Rita
>|||Hi Tibor,
Thanks for your response.
I'm trying to figure out how to use it along with a CASE statement.
Here's my code:
INSERT INTO MyTable(
Col1,
Col2,
etc.)
SELECT
CASE
WHEN Left(SM.Discount_Specification, 2) IN (@.P, @.L) THEN
Something
ELSE 1
END,
CASE
WHEN Left(SM.Discount_Specification, 2) = @.K THEN
SomethingElse
ELSE 1
END,
Etc.
From MyTable
Thanks,
Rita
"Tibor Karaszi" wrote:
> Hard to say without DDL, but perhaps something like:
> INSERT INTO ...
> SELECT ds, ds + 'a', col2
> FROM
> (
> SELECT LEFT(Discout_Specification, 2) AS ds, col2 FROM tbl
> ) AS t
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "RitaG" <RitaG@.discussions.microsoft.com> wrote in message
> news:A07835AD-AAC2-4225-BA8C-FDA70C1C0631@.microsoft.com...
>|||Is this a "lazy programmer doesn't want to type all those keystrokes" issue
or something else? It is possible that "Left(SM.Discount_Specification, 2)"
indicates a schema issue. If so, you should consider a change to the schema
to unbind the two attributes currently stored in the Discount_Specification
column. This can be done permanently via the addition of another column
(and the movement of the associated information), via a view, or via a
computed column, via a udf, etc. You can also do this via a derived table
within this particular query.
insert ...
select case when derived_discount in (@.P, @.L) then x else y end,
...
from
(select Left(SM.Discount_Specification, 2) as derived_discount,
...
from MyTable ) as t1
where ...|||Hi Scott,
No, it's not a "lazy programmer"! :-)
I just thought there may be a more efficient way since I'm dealing with a
large volume of rows (up to 10 million).
Thanks for your reponse. That was what I was looking for.
Rita
"Scott Morris" wrote:
> Is this a "lazy programmer doesn't want to type all those keystrokes" issu
e
> or something else? It is possible that "Left(SM.Discount_Specification, 2
)"
> indicates a schema issue. If so, you should consider a change to the sche
ma
> to unbind the two attributes currently stored in the Discount_Specificatio
n
> column. This can be done permanently via the addition of another column
> (and the movement of the associated information), via a view, or via a
> computed column, via a udf, etc. You can also do this via a derived table
> within this particular query.
> insert ...
> select case when derived_discount in (@.P, @.L) then x else y end,
> ...
> from
> (select Left(SM.Discount_Specification, 2) as derived_discount,
> ...
> from MyTable ) as t1
> where ...
>
>