Showing posts with label fields. Show all posts
Showing posts with label fields. Show all posts

Tuesday, March 20, 2012

check if cast is possible

I use to import data from DBF Clipper databases into SQL Server. When a table is just imported its date fields have string format. I need to copy their data to tables of database where they ahve to be converted into date. Direct operator INSERT doesn't convert properly (I've not successed in changing default date format so it'll be covertable) but using CAST I can get result of strings like 13.05.1970 0:00:00 as datetime type. But not all records can be coverted this way. For ones can't be converted I've solved to make NULL fields there. But I don't know how to make CAST operation return NULL when convertion isn't possible. The query
INSERT INTO people_temp
(reg_num, surname, stname, patronymic, foreing, gender, birthdate, fam_pos, dwell_type, children, nation, par_not, region, stud_fml, parn_fml,
com_prob, sp_prob, sn_passport, nn_passport, dv_passport, wg_passport)
SELECT STUDENTs_temp.REG_NOM, STUDENTs_temp.FAMILY, STUDENTs_temp.NAME, STUDENTs_temp.PARN_NAME, STUDENTs_temp.INOSTR,

STUDENTs_temp.SEX,
CAST(PSPR_temp.DATA_BORN AS smalldatetime), PSPR_temp.SEM_POL, PSPR_temp.XAR_JT, PSPR_temp.CHILDREN,

PSPR_temp.NATION,
PSPR_temp.SV_ROD1 + PSPR_temp.SV_ROD2 AS Expr1, PSPR_temp.REGION, PSPR_temp.STUD_FML,

PSPR_temp.PARN_FML,
PSPR_temp.OB_STAJ, PSPR_temp.SP_STAJ, PSPR_temp.SN_PASPORT, PSPR_temp.NN_PASPORT, PSPR_temp.DV_PASPORT,
PSPR_temp.WG_PASPORT
FROM STUDENTs_temp INNER JOIN
PSPR_temp ON STUDENTs_temp.REG_NOM = PSPR_temp.REG_NOM
gets an error 'The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value'. Tell me please how can make type casting return NULL if convertion isn't possible.I might try something like so:

Insert Into MyTable(MyDateField)
SELECT (CASE WHEN isDate(DateFieldTobeImported) = 1 Then DateFieldTobeImported ELSE Null End)
From TableBeingImported

If this does not work, please post some sample data.|||Thank you, it works.

Monday, March 19, 2012

check fields in select statement

hi,

I am getting some fields back from a select statement, how do you check one of the fields and display a string depending on what it is? Is there something like an if statement you can use? for example

select

field1,
field2 /*how do you check to see what it is here and display something depending on what it is*/

from
record

I am trying to see if field2 is a '' or empty string character

thxYou use a CASE statement.


SELECT field1, CASE field2 WHEN '' THEN 'BLANK' ELSE field2 END as Field2 FROM Table

If rather than '' the value might be null, you can use ISNULL


SELECT field1, ISNULL(field2,'BLANK') as field2 FROM Table
|||thank you for the help

Saturday, February 25, 2012

Charts

In this release, the value fields for a chart must be aggregates. If you
don’t have the aggregate you need, you can create a custom field (name
it whatever you want) and wrap the base field in the SUM() aggregate
function, which should be a no-op in this case.Hi Bob,
Thanks a bunch! That did work!

Charting Trouble

Well, this is what is happening.
I am getting my data from a stored procedure, and for this particular chart
am need to use 4 different data fields, 'AverageFillRate',
'AverageFillRateTarget', 'Years', and 'Months'. The years need to correspond
to the averagefillrate, so for example, between 2004 and 2006 I will have 3
fill rates, but the averagefillratetarget is constant among all years.
This is the way the legend appears now:
-- 2004 Average Fill Rate
-- 2004 Average Fill Rate Target
-- 2005 Average Fill Rate
-- 2005 Average Fill Rate Target
-- 2006 Average Fill Rate
-- 2006 Average Fill Rate Target
I need it to be:
-- Average Fill Rate Target
-- 2004 Average Fill Rate
-- 2005 Average Fill Rate
-- 2006 Average Fill Rate
..... etc
Since the target is constant among all years, it does not need to correspond
to any year field, and should be a straight line across the chart. Then I
should have another three different lines on the chart corresponding to the
years selected. But I have 6 lines, because I am getting a target line for
each year as well, this is a mess.
Right now I have 'AverageFillRateTarget' and 'AverageFillRate' fields
dropped into the data field area, 'Months' dropped into the category field
area and 'Years' dropped into the series field area of the chart.
Any suggestions, and does this help any?
ThanksPlease check my response on your other thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=1ca451e6-5cc2-43fc-9fd9-bb51e1a3967d&sloc=en-us
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Spencer23" <Spencer23@.discussions.microsoft.com> wrote in message
news:5B978BF7-4D62-4D5C-9355-163AB6F7FCF3@.microsoft.com...
> Well, this is what is happening.
> I am getting my data from a stored procedure, and for this particular
chart
> am need to use 4 different data fields, 'AverageFillRate',
> 'AverageFillRateTarget', 'Years', and 'Months'. The years need to
correspond
> to the averagefillrate, so for example, between 2004 and 2006 I will have
3
> fill rates, but the averagefillratetarget is constant among all years.
> This is the way the legend appears now:
> -- 2004 Average Fill Rate
> -- 2004 Average Fill Rate Target
> -- 2005 Average Fill Rate
> -- 2005 Average Fill Rate Target
> -- 2006 Average Fill Rate
> -- 2006 Average Fill Rate Target
>
> I need it to be:
> -- Average Fill Rate Target
> -- 2004 Average Fill Rate
> -- 2005 Average Fill Rate
> -- 2006 Average Fill Rate
> ..... etc
>
> Since the target is constant among all years, it does not need to
correspond
> to any year field, and should be a straight line across the chart. Then I
> should have another three different lines on the chart corresponding to
the
> years selected. But I have 6 lines, because I am getting a target line for
> each year as well, this is a mess.
> Right now I have 'AverageFillRateTarget' and 'AverageFillRate' fields
> dropped into the data field area, 'Months' dropped into the category field
> area and 'Years' dropped into the series field area of the chart.
> Any suggestions, and does this help any?
> Thanks

Chart Y-axis Values Problem

I created a chart using some calculated fields, the calculations are working
correctly (I manually checked the math), but the Y axis values are way off.
The highest field value generated was 18,544 but the scale on the chart was
showing 500,000 with the bar reaching nearly to the top. I could understand
if the scale was just off and the bar stopped at the correct position, but
not only is the scale off, the bar doesn't correctly represent the value
either. Because this report will be used for several customers I can't
manually set a limit for the Y-axis. I turned off the labels for the Y-axis
so that I can use the chart, but I would prefer being able to see the labels.
I have installed SP1. Any help would be appreciated.
JoeHi, you can convert the scale of your chart in a expression in the RDL; try
it.
John Bocachica
Colombia
"JHoward" <JHoward@.discussions.microsoft.com> wrote in message
news:78D0BEDF-A212-4B07-9641-9A1615E6168F@.microsoft.com...
>I created a chart using some calculated fields, the calculations are
>working
> correctly (I manually checked the math), but the Y axis values are way
> off.
> The highest field value generated was 18,544 but the scale on the chart
> was
> showing 500,000 with the bar reaching nearly to the top. I could
> understand
> if the scale was just off and the bar stopped at the correct position, but
> not only is the scale off, the bar doesn't correctly represent the value
> either. Because this report will be used for several customers I can't
> manually set a limit for the Y-axis. I turned off the labels for the
> Y-axis
> so that I can use the chart, but I would prefer being able to see the
> labels.
> I have installed SP1. Any help would be appreciated.
> Joe|||Note: expression-based min/max/intervals will only be available on RS2005.
Joe, can you post a simplified report which runs e.g. based on Northwind
data and reproduces the issue?
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"John Bocachica (Colombia)" <jbocachica@.gmail.com> wrote in message
news:e%23FQGGl%23EHA.1084@.tk2msftngp13.phx.gbl...
> Hi, you can convert the scale of your chart in a expression in the RDL;
try
> it.
> John Bocachica
> Colombia
> "JHoward" <JHoward@.discussions.microsoft.com> wrote in message
> news:78D0BEDF-A212-4B07-9641-9A1615E6168F@.microsoft.com...
> >I created a chart using some calculated fields, the calculations are
> >working
> > correctly (I manually checked the math), but the Y axis values are way
> > off.
> > The highest field value generated was 18,544 but the scale on the chart
> > was
> > showing 500,000 with the bar reaching nearly to the top. I could
> > understand
> > if the scale was just off and the bar stopped at the correct position,
but
> > not only is the scale off, the bar doesn't correctly represent the value
> > either. Because this report will be used for several customers I can't
> > manually set a limit for the Y-axis. I turned off the labels for the
> > Y-axis
> > so that I can use the chart, but I would prefer being able to see the
> > labels.
> > I have installed SP1. Any help would be appreciated.
> >
> > Joe
>

Chart with Data Fields from Multiple Queries

Is there any way to create a chart using data fields from more that one query?

I tried to create two different datasets, but the chart has to be bound to only one dataset. So when I drop the data field from the second dataset onto the chart I get a SQL error.

I've also tried UNION ALL. Each of these queries is correct by itself, but UNION ALL combines GLBUDAMOUNT and GLTRXAMOUNT into one field. I need them to be two different fields so that I can do GLBUDAMOUNT VS GLTRXAMOUNT in the chart.


Solved using a simple case statement.

Chart with 3 year series

Hello
I have a dataset with a date field and a value field. I wish to display the
value fields for current year as well as the previous 2 years together with
different colours on the same month interval on the X-axis. Can someone lend
a hand on how to do this?
thanks in advance
Chris PulfordExample is attached below. The basic idea is to group by months on the
categories and group by year on the series.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
tion"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<RightMargin>1in</RightMargin>
<Body>
<ReportItems>
<Chart Name="Sales">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<Style />
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<Color>Brown</Color>
</Style>
<Position>RightCenter</Position>
</Legend>
<Palette>Pastel</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitPrice.Value *
Fields!Quantity.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BorderWidth>
<Default>6pt</Default>
</BorderWidth>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Marker />
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title>
<Style />
</Title>
<Style />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Visible>true</Visible>
</Axis>
</CategoryAxis>
<DataSetName>Northwind</DataSetName>
<PointWidth>100</PointWidth>
<Type>Line</Type>
<Title>
<Caption>Sales</Caption>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>700</FontWeight>
</Style>
</Title>
<CategoryGroupings>
<CategoryGrouping>
<DynamicCategories>
<Grouping Name="Sales_CategoryGroup1">
<GroupExpressions>
<GroupExpression>=Month(Fields!OrderDate.Value)</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Month(Fields!OrderDate.Value)</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=MonthName(Month(Fields!OrderDate.Value))</Label>
</DynamicCategories>
</CategoryGrouping>
</CategoryGroupings>
<Height>6.125in</Height>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="Sales_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Year(Fields!OrderDate.Value)</GroupExpression>
</GroupExpressions>
</Grouping>
<Label />
</DynamicSeries>
</SeriesGrouping>
<SeriesGrouping>
<StaticSeries>
<StaticMember>
<Label>Sales</Label>
</StaticMember>
</StaticSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundGradientEndColor>White</BackgroundGradientEndColor>
<BackgroundGradientType>TopBottom</BackgroundGradientType>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<ValueAxis>
<Axis>
<Title>
<Style />
</Title>
<Style />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<MinorTickMarks>Outside</MinorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
</ReportItems>
<Style />
<Height>6.5in</Height>
</Body>
<TopMargin>1in</TopMargin>
<DataSources>
<DataSource Name="Northwind">
<rd:DataSourceID>da5964d0-11a7-4e51-9b22-cc4fa55fdd7a</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=(local);initial
catalog=Northwind</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<Width>6.5in</Width>
<DataSets>
<DataSet Name="Northwind">
<Fields>
<Field Name="UnitPrice">
<DataField>UnitPrice</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="Quantity">
<DataField>Quantity</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="OrderDate">
<DataField>OrderDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>Northwind</DataSourceName>
<CommandText>SELECT [Order Details].UnitPrice, [Order
Details].Quantity, Orders.OrderDate
FROM Orders INNER JOIN
[Order Details] ON Orders.OrderID = [Order
Details].OrderID</CommandText>
<Timeout>30</Timeout>
</Query>
</DataSet>
</DataSets>
<LeftMargin>1in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>bc811835-2302-4f9e-9c89-a99d4d3f5fd2</rd:ReportID>
<BottomMargin>1in</BottomMargin>
</Report>

Friday, February 24, 2012

Chart Legened problem

I have a chart -pie which shows data from 5 fields(each field is a slice in
the pie).
When one of them is null or 0 there won't be a slice for this field,but this
fiels is shown in the legened of the chart,can it be disapeared?You could remove this e.g. by adding a filter on the chart or on chart
groups.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"'" <@.discussions.microsoft.com> wrote in message
news:D4B6CA0A-877B-45CE-9070-E5A944CA812F@.microsoft.com...
>I have a chart -pie which shows data from 5 fields(each field is a slice in
> the pie).
> When one of them is null or 0 there won't be a slice for this field,but
> this
> fiels is shown in the legened of the chart,can it be disapeared?

Sunday, February 19, 2012

Chart dataset error from sql sum fields

I'm receiving an,
"The expression for the chart â'chart1â' refers to the field â'Bill_Sumâ'.
Report item expressions can only refer to fields within the current data set
scope or, if inside an aggregate, the specified data set scope."
Error whenever I use the fields from my similar running total query
SELECT a.DayCount,
a.Sales,
SUM(b.Sales)
FROM Sales a
CROSS JOIN Sales b
WHERE (b.DayCount <= a.DayCount) AS RunningTotal
GROUP BY a.DayCount,a.Sales
ORDER BY a.DayCount,a.Sales
Anyone run into a similar problem?Just in case anyone else has this problem
if in your select you use a Sum and it will automatically convert it to a
name like AS expr1, Change the expr to that field.
Ex:
Select Sum(Distinct Something.FieldName) As Expr1
Change Expr1 to FieldName and it should work in the graph.
Don't know why I was getting this error.
"Sean Edwards" wrote:
> I'm receiving an,
> "The expression for the chart â'chart1â' refers to the field â'Bill_Sumâ'.
> Report item expressions can only refer to fields within the current data set
> scope or, if inside an aggregate, the specified data set scope."
> Error whenever I use the fields from my similar running total query
> SELECT a.DayCount,
> a.Sales,
> SUM(b.Sales)
> FROM Sales a
> CROSS JOIN Sales b
> WHERE (b.DayCount <= a.DayCount) AS RunningTotal
> GROUP BY a.DayCount,a.Sales
> ORDER BY a.DayCount,a.Sales
> Anyone run into a similar problem?

chart category field

On the category fields, how is it possible to show the first and the last
values. I.e. the x-axis to show the min value at the start and the max value
at the end.
This is what i have so far but the x-axis displays nothing on the line
=IIf(Min(Fields!Import_Date.Value),Fields!Import_Date.Value,"")This is a work around which I have used in the past but may not be
what you want. You can turn off the axis and create a table item under
your chart to simulate what you are after.
On Nov 20, 11:20 pm, arkiboys2 <arkibo...@.discussions.microsoft.com>
wrote:
> On the category fields, how is it possible to show the first and the last
> values. I.e. the x-axis to show the min value at the start and the max value
> at the end.
> This is what i have so far but the x-axis displays nothing on the line
> =IIf(Min(Fields!Import_Date.Value),Fields!Import_Date.Value,"")|||What is a table item please?
"shaikat.das@.gmail.com" wrote:
> This is a work around which I have used in the past but may not be
> what you want. You can turn off the axis and create a table item under
> your chart to simulate what you are after.
>
> On Nov 20, 11:20 pm, arkiboys2 <arkibo...@.discussions.microsoft.com>
> wrote:
> > On the category fields, how is it possible to show the first and the last
> > values. I.e. the x-axis to show the min value at the start and the max value
> > at the end.
> >
> > This is what i have so far but the x-axis displays nothing on the line
> >
> > =IIf(Min(Fields!Import_Date.Value),Fields!Import_Date.Value,"")
>|||In visual studio , under the toolbox, youll find a table . Drag that
onto the designer, under the x-axis . Make the width of the table same
as the width of your graph and turn off header and footer on the
table. Then create a dataset which has the least and max values which
you want to show on your x axis. Tie this data set to your table and
place the least value in the first cell and the max value in the last
cell. Turn off your x axis and play with the table till you get it to
look like what you need.
Cheers
Shai
On Nov 21, 8:47 pm, arkiboys2 <arkibo...@.discussions.microsoft.com>
wrote:
> What is a table item please?
>
> "shaikat...@.gmail.com" wrote:
> > This is a work around which I have used in the past but may not be
> > what you want. You can turn off the axis and create a table item under
> > your chart to simulate what you are after.
> > On Nov 20, 11:20 pm, arkiboys2 <arkibo...@.discussions.microsoft.com>
> > wrote:
> > > On the category fields, how is it possible to show the first and the last
> > > values. I.e. the x-axis to show the min value at the start and the max value
> > > at the end.
> > > This is what i have so far but the x-axis displays nothing on the line
> > > =IIf(Min(Fields!Import_Date.Value),Fields!Import_Date.Value,"")- Hide quoted text -
> - Show quoted text -

Thursday, February 16, 2012

Characters not to use in Table and Field Names: your opinion/experiences

Hi,
I know we can use several non-alpha characters in the names of Tables and
Fields, but I still think it's not a good rpactice. The same thing with the
spaces etc, which can be used, but tiwh the brackets []. Microsoft even uses
underscore_ in their own tables, but still I don't like it because I guess
it could mess up when using the _ for a wildcard.
So I actually prefer not to use Table and field names with special
(non-alpha) characters. Reserved words aren't done either!
And what about figures? I can't really find an exemple wheir it could harm
something, but I don't like it either. Can anybody give me some more info
about this? And any idea about non-alpha characters that can be used safely?
All this not only taking in my Sql Server itself, but also programming
languages that use these databases (especially .NET).
PieterMy personal preference is to have purely alphabetical table and column
names. For example, ProductID is much more preferable than Product_ID or
[Product-ID] or [Product ID]
Not having these non-alphabetic and special characters in the names makes it
much easier to type things when I am busily troubleshooting something for
example.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:%23Jsbr6$lFHA.572@.TK2MSFTNGP15.phx.gbl...
Hi,
I know we can use several non-alpha characters in the names of Tables and
Fields, but I still think it's not a good rpactice. The same thing with the
spaces etc, which can be used, but tiwh the brackets []. Microsoft even uses
underscore_ in their own tables, but still I don't like it because I guess
it could mess up when using the _ for a wildcard.
So I actually prefer not to use Table and field names with special
(non-alpha) characters. Reserved words aren't done either!
And what about figures? I can't really find an exemple wheir it could harm
something, but I don't like it either. Can anybody give me some more info
about this? And any idea about non-alpha characters that can be used safely?
All this not only taking in my Sql Server itself, but also programming
languages that use these databases (especially .NET).
Pieter

Tuesday, February 14, 2012

character strings as primary keys

Hello,

How bad is normalizing the database to the 3rd form, which requires that all fields depend on nothing but primary key. Consider the first table you create -- users. They have int primary keys, which duplicate the real primary keys -- user names. When user logs in, the user's entry is uniquely identified by its name, which is not primary key. The fundamental design rule -- avoid redundancy -- is violated. A VERY serious reason should be there for that.

Usually, design is compromised by redundancy for performance. Here, both copies are stored in one remote database, but integer keys may be located/used faster. Additionally, using long string references everywhere instead of short integer keys may save a lot of storage space (additionally increasing speed). How serious these impacts are? Am I missing something?

Usually, login names are not allowed to change. You have problems changing primary keys because all the foreign keys must be updated accordingly. Does it reveal that most user databases use character strings as primary keys?

Valentin,

Names are rarely UNIQUE -a primary requirement for a Primary Key. You only have to look at a telephone book to see that using Names as a Primary Key will be impossible. (Granted, a few 'small' countries mandate name uniqueness.)

From: http://howmanyofme.com/people/John_Smith/

There are 49,842 people in the U.S. named John Smith.

User Names, while sometimes, in small systems, seem unique, and seem suitable for Primary Key usage, will, over time prove to be a significant problem. Then the system will have to devolve to using ( Name + identifier ), e.g., JohnSmith1, JohnSmith2, etc. I have found that it is so problemmatic to use Names as keys that is is not worth even considering. As you indicate, Names 'should' allow for changes, i.e, marriage, divorce, etc. But the Primary Key 'should not' change. If you consider the domain security system, the User Name is NOT the Primary Key, and the Login Name is changable. The Primary Key is the SID, a unique identifier normally hidden from view, somewhat like using a IDENTITY field (or other indentifier) -in fact, a surrogate key. (Beware: simplistic explanition.)

It is extremely difficult to design a system for identifying People with a 'natural' Primary Key. Some adamately espouse using the SSN (in the USA) as a Primary Key. But it is NOT a naturally occuring characteristic of the individual -it is a surrogate key created by a remote system. It is legally protected, and increased being enforced, as 'sensitive' data. Most data systems 'should' NOT use the SSN as a Primary Key -of course, exceptions are allowed, or required, by law. So what does that leave as a naturally occuring characteristic of the entity -nothing really, except perhaps biometrics. Now try using the DNA sequence as a key -talk about size... (Though I know of some attempts to synthesize through the sequence redundancy to create smaller and more usable keys. -Think DNA/Fingerprint/Biometric databases.)

From: http://www.eogn.com/archives/news0202.htm

The fact that DNA is inherited and that each individual is the product of his/her progenitors means that DNA can be used to not only create unique identifications, but also to identify members of the same family, the same clan or tribal group, or the same population.

I hope I have sufficiently challenged your assertion that names are usable as primary keys.

... which duplicate the real primary keys -- user names.

A Passport number a NOT good Primary Key candidate -many people do not have a passport.

A Driver's License Number is NOT a good Primary Key candidate -many people do not have one.

So the real question is, in my system, for our business needs, what are appropriate surrogate keys?

|||By the character strings, I did not mean the real names. It is clear that real people can be namesakes. But in the internet, rarely anybody uses their numeric ids. For instance, Microsoft uses emails as user identifiers. The DNS maps between real IP addresses and memorizable symbolic names. People enjoy having fancy monikers.
|||Trying to grasp the subtle difference between "is unique" indeces and "unique key" columns, I came across the following text:


SQL Server 2005 Books Online

Unique Index Design Guidelines
Designing and Creating Databases > Indexes > Designing Indexes >

A unique index guarantees that the index key contains no duplicate values and therefore every row in the table is in some way unique. Specifying a unique index makes sense only when uniqueness is a characteristic of the data itself. For example, if you want to make sure that the values in the NationalIDNumber column in the HumanResources.Employee table are unique, when the primary key is EmployeeID, create a UNIQUE constraint on the NationalIDNumber column. If the user tries to enter the same value in that column for more than one employee, an error message is displayed and the duplicate value is not entered.

The engine designers foresee the situation where there is a redundancy -- two key columns in a table. But they do not explain why there may appear a need for such abnormal relation. Isn't EmployeeID redundant if they are identified by national id?

|||I think you are confusing a "primary key" with a "unique index/constraint".

I "primary key" is the link between other tables. For example, you are not, and should not, be linking Employees to Addressses by the "EmployeeName" field, you use the "EmployeeID".

Also, you NEVER EVER use a link between tables which the user could to change. Otherwise, you need to update every single table which links to the item.

For linking tables, you want very fast linking. Integers are 1000 times faster links than using a character string.

In your case, you are only wanting the "loginname" to be UNIQUE, not the link between tables. They are two totally different things and conform to the normalization rule because you don't duplicate "loginname" in other tables.

|||

Tom Phillips wrote:

I think you are confusing a "primary key" with a "unique index/constraint".


Yes, to things for the same (unique ID) purpose cannot be not confusing.

Tom Phillips wrote:


I "primary key" is the link between other tables. For example, you are not, and should not, be linking Employees to Addressses by the "EmployeeName" field, you use the "EmployeeID".


What is the problem to use the unique key "NationalID" for linking instead of EmploeeID primary key? Please, do not tell that the Microsoft decided so.

Tom Phillips wrote:


Also, you NEVER EVER use a link between tables which the user could to change. Otherwise, you need to update every single table which links to the item.

For linking tables, you want very fast linking. Integers are 1000 times faster links than using a character string.

This is what I wanted to see. It is not obvious, since the hash tables reach O(1) efficiency by hashing strings as well as serial numbers and the speed could easily be of the same order.

Tom Phillips wrote:


In your case, you are only wanting the "loginname" to be UNIQUE, not the link between tables. They are two totally different things and conform to the normalization rule because you don't duplicate "loginname" in other tables.

In my case I want to know the reason for overcomplicating the relations by inferring the redundant IDs to the emails I already have. The redundancy does violate the normalization as I have explained before. Normalization = elimination of redundancy.

|||

Another reason not to use SSN. SSN is not guaranteed to be unique.

Credit agencies got burned by this in the past|||

Valentin,

There are times when it is necessary to handle what you classsify as 'redundancy'. For example, in the USA, it is necessary to have an Employees TaxID number stored and available for government related reports and tax filings. However, that is 'protected' and sensitive data, and therefor 'should' NOT be used as a Primary Key for normal reports and operations. And we don't have 'mandated' NationalID number -yet.

Isn't EmployeeID redundant if they are identified by national id?

So in most situations, there will be an EmployeeID, Primary Key, and also a need to verify and be certain that there are no duplicate TaxIDs. So the Unique Constraint (Unique Index) helps in that respect.

With a Unique Constraint, you DO NOT have to have a value (as a Primary Key requires) -BUT if you do provide a value, it must be UNIQUE.

|||They are not the "same thing". They are used for different purposes. The ONLY thing the same is they are both unique. They are not redundant.

You NEVER, EVER link tables on a user changeable data. In the MS example, I assume, "NationalID" is a user entered field (probably Social Security Number). Although, it needs to be unique, because 2 people cannot have the same number, the user MIGHT change it for many reasons (it was entered wrong or changed for some other reason). Therefore, you do not link tables on the NationalID field. You use the EmployeeID field, which is also unique, but NEVER changes after it is created by the software.

From what you describe in your situation, lets say you have 2 tables:

User:
UserID INT IDENTITY(1,1) PK
UserName varchar(50)
UserEmailAddress varchar(255) (this is the max size of an SMTP email address) UNIQUE

LoginData:
LoginID INT IDENTITY(1,1) PK
UserID INT FK to User
LoginDate DATETIME

What would happen if the user changes his/her email address? The answer, NOTHING.

What I think you are suggesting is the following:

User:
UserID INT IDENTITY(1,1) PK
UserName varchar(50)
UserEmailAddress varchar(255) UNIQUE (this is the max size of an SMTP email address)

LoginData:
LoginID INT IDENTITY(1,1) PK
UserEmailAddress varchar(255) FK to User
LoginDate DATETIME

Now if the email address changes, you need to change every record in LoginData AND you have violated normalization rules by duplicating USER DATA (UserEmailAddress) in your tables. Also, you have made your table linking take 10,000 times longer to search by using a varchar(255) rather than the int.

|||Now, lets further complicate your issue by talking about adding some way to find "Last Login Date".

Normalization would say, you have it:

SELECT MAX(LoginData.LoginDate) FROM LoginData WHERE LoginID=@.LoginID

However, it is a terrible waste of time to scan 1 billion records.

FYI, in MS SQL (but no other engine) you could do:

SELECT TOP 1 LoginData.LoginDate FROM LoginData WHERE LoginID=@.LoginID ORDER BY LoginData.LoginDate DESC

So most people would just add "LastLoginDate datetime" to User and update it when the user logged in.

Yes, it violates normalization rules, but one field is nothing. Then it is 2, then 10, then 100 and then normalization is out the window. Smile

|||

Tom Phillips wrote:

They are not the "same thing". They are used for different purposes. The ONLY thing the same is they are both unique. They are not redundant.

You NEVER, EVER link tables on a user changeable data. In the MS example, I assume, "NationalID" is a user entered field (probably Social Security Number). Although, it needs to be unique, because 2 people cannot have the same number, the user MIGHT change it for many reasons (it was entered wrong or changed for some other reason). Therefore, you do not link tables on the NationalID field. You use the EmployeeID field, which is also unique, but NEVER changes after it is created by the software.

<skip>
Now if the email address changes, you need to change every record in LoginData AND you have violated normalization rules by duplicating USER DATA (UserEmailAddress) in your tables. Also, you have made your table linking take 10,000 times longer to search by using a varchar(255) rather than the int.

The fact that changing primary key (like object address in a program) is problematic does not mean that adding an extra reference you do no incur a redundancy.

Arnie Rowland wrote:

Valentin,

There are times when it is necessary to handle what you classsify as 'redundancy'. For example, in the USA, it is necessary to have an Employees TaxID number stored and available for government related reports and tax filings. However, that is 'protected' and sensitive data, and therefor 'should' NOT be used as a Primary Key for normal reports and operations. And we don't have 'mandated' NationalID number -yet.

But I'm addressing the case when the symbolic name is unique and mandatory. In our app, user logs in by email. In this case, email is not just unique. Since it is used to uniquely identify users, it is a key (nulls are not allowed). The int ID uses the same purpose. It duplicates the email field. The same situations I have in 'groups' table where human-manageable groups must have unique names but we refer the groups by ID. In addition to being redundant, the design overcomplicates the things because user normally wants to see the group (s)he belongs in text rather than an integer id of the group.

Though, the keys are duplicated, I cannot bring an inconsistency example, which proves the redundancy. But 3rd normal form requires the record fields to depend only on the primary key. Meantime, users in my database are identified/refered/addressed/pointed to by email. It is a natural primary key. Integer IDs were artificially introduced to do the same job.

character strings as primary keys

Hello,

How bad is normalizing the database to the 3rd form, which requires that all fields depend on nothing but primary key. Consider the first table you create -- users. They have int primary keys, which duplicate the real primary keys -- user names. When user logs in, the user's entry is uniquely identified by its name, which is not primary key. The fundamental design rule -- avoid redundancy -- is violated. A VERY serious reason should be there for that.

Usually, design is compromised by redundancy for performance. Here, both copies are stored in one remote database, but integer keys may be located/used faster. Additionally, using long string references everywhere instead of short integer keys may save a lot of storage space (additionally increasing speed). How serious these impacts are? Am I missing something?

Usually, login names are not allowed to change. You have problems changing primary keys because all the foreign keys must be updated accordingly. Does it reveal that most user databases use character strings as primary keys?

Valentin,

Names are rarely UNIQUE -a primary requirement for a Primary Key. You only have to look at a telephone book to see that using Names as a Primary Key will be impossible. (Granted, a few 'small' countries mandate name uniqueness.)

From: http://howmanyofme.com/people/John_Smith/

There are 49,842 people in the U.S. named John Smith.

User Names, while sometimes, in small systems, seem unique, and seem suitable for Primary Key usage, will, over time prove to be a significant problem. Then the system will have to devolve to using ( Name + identifier ), e.g., JohnSmith1, JohnSmith2, etc. I have found that it is so problemmatic to use Names as keys that is is not worth even considering. As you indicate, Names 'should' allow for changes, i.e, marriage, divorce, etc. But the Primary Key 'should not' change. If you consider the domain security system, the User Name is NOT the Primary Key, and the Login Name is changable. The Primary Key is the SID, a unique identifier normally hidden from view, somewhat like using a IDENTITY field (or other indentifier) -in fact, a surrogate key. (Beware: simplistic explanition.)

It is extremely difficult to design a system for identifying People with a 'natural' Primary Key. Some adamately espouse using the SSN (in the USA) as a Primary Key. But it is NOT a naturally occuring characteristic of the individual -it is a surrogate key created by a remote system. It is legally protected, and increased being enforced, as 'sensitive' data. Most data systems 'should' NOT use the SSN as a Primary Key -of course, exceptions are allowed, or required, by law. So what does that leave as a naturally occuring characteristic of the entity -nothing really, except perhaps biometrics. Now try using the DNA sequence as a key -talk about size... (Though I know of some attempts to synthesize through the sequence redundancy to create smaller and more usable keys. -Think DNA/Fingerprint/Biometric databases.)

From: http://www.eogn.com/archives/news0202.htm

The fact that DNA is inherited and that each individual is the product of his/her progenitors means that DNA can be used to not only create unique identifications, but also to identify members of the same family, the same clan or tribal group, or the same population.

I hope I have sufficiently challenged your assertion that names are usable as primary keys.

... which duplicate the real primary keys -- user names.

A Passport number a NOT good Primary Key candidate -many people do not have a passport.

A Driver's License Number is NOT a good Primary Key candidate -many people do not have one.

So the real question is, in my system, for our business needs, what are appropriate surrogate keys?

|||By the character strings, I did not mean the real names. It is clear that real people can be namesakes. But in the internet, rarely anybody uses their numeric ids. For instance, Microsoft uses emails as user identifiers. The DNS maps between real IP addresses and memorizable symbolic names. People enjoy having fancy monikers.
|||Trying to grasp the subtle difference between "is unique" indeces and "unique key" columns, I came across the following text:


SQL Server 2005 Books Online

Unique Index Design Guidelines
Designing and Creating Databases > Indexes > Designing Indexes >

A unique index guarantees that the index key contains no duplicate values and therefore every row in the table is in some way unique. Specifying a unique index makes sense only when uniqueness is a characteristic of the data itself. For example, if you want to make sure that the values in the NationalIDNumber column in the HumanResources.Employee table are unique, when the primary key is EmployeeID, create a UNIQUE constraint on the NationalIDNumber column. If the user tries to enter the same value in that column for more than one employee, an error message is displayed and the duplicate value is not entered.

The engine designers foresee the situation where there is a redundancy -- two key columns in a table. But they do not explain why there may appear a need for such abnormal relation. Isn't EmployeeID redundant if they are identified by national id?

|||I think you are confusing a "primary key" with a "unique index/constraint".

I "primary key" is the link between other tables. For example, you are not, and should not, be linking Employees to Addressses by the "EmployeeName" field, you use the "EmployeeID".

Also, you NEVER EVER use a link between tables which the user could to change. Otherwise, you need to update every single table which links to the item.

For linking tables, you want very fast linking. Integers are 1000 times faster links than using a character string.

In your case, you are only wanting the "loginname" to be UNIQUE, not the link between tables. They are two totally different things and conform to the normalization rule because you don't duplicate "loginname" in other tables.

|||

Tom Phillips wrote:

I think you are confusing a "primary key" with a "unique index/constraint".


Yes, to things for the same (unique ID) purpose cannot be not confusing.

Tom Phillips wrote:


I "primary key" is the link between other tables. For example, you are not, and should not, be linking Employees to Addressses by the "EmployeeName" field, you use the "EmployeeID".


What is the problem to use the unique key "NationalID" for linking instead of EmploeeID primary key? Please, do not tell that the Microsoft decided so.

Tom Phillips wrote:


Also, you NEVER EVER use a link between tables which the user could to change. Otherwise, you need to update every single table which links to the item.

For linking tables, you want very fast linking. Integers are 1000 times faster links than using a character string.

This is what I wanted to see. It is not obvious, since the hash tables reach O(1) efficiency by hashing strings as well as serial numbers and the speed could easily be of the same order.

Tom Phillips wrote:


In your case, you are only wanting the "loginname" to be UNIQUE, not the link between tables. They are two totally different things and conform to the normalization rule because you don't duplicate "loginname" in other tables.

In my case I want to know the reason for overcomplicating the relations by inferring the redundant IDs to the emails I already have. The redundancy does violate the normalization as I have explained before. Normalization = elimination of redundancy.

|||

Another reason not to use SSN. SSN is not guaranteed to be unique.

Credit agencies got burned by this in the past|||

Valentin,

There are times when it is necessary to handle what you classsify as 'redundancy'. For example, in the USA, it is necessary to have an Employees TaxID number stored and available for government related reports and tax filings. However, that is 'protected' and sensitive data, and therefor 'should' NOT be used as a Primary Key for normal reports and operations. And we don't have 'mandated' NationalID number -yet.

Isn't EmployeeID redundant if they are identified by national id?

So in most situations, there will be an EmployeeID, Primary Key, and also a need to verify and be certain that there are no duplicate TaxIDs. So the Unique Constraint (Unique Index) helps in that respect.

With a Unique Constraint, you DO NOT have to have a value (as a Primary Key requires) -BUT if you do provide a value, it must be UNIQUE.

|||They are not the "same thing". They are used for different purposes. The ONLY thing the same is they are both unique. They are not redundant.

You NEVER, EVER link tables on a user changeable data. In the MS example, I assume, "NationalID" is a user entered field (probably Social Security Number). Although, it needs to be unique, because 2 people cannot have the same number, the user MIGHT change it for many reasons (it was entered wrong or changed for some other reason). Therefore, you do not link tables on the NationalID field. You use the EmployeeID field, which is also unique, but NEVER changes after it is created by the software.

From what you describe in your situation, lets say you have 2 tables:

User:
UserID INT IDENTITY(1,1) PK
UserName varchar(50)
UserEmailAddress varchar(255) (this is the max size of an SMTP email address) UNIQUE

LoginData:
LoginID INT IDENTITY(1,1) PK
UserID INT FK to User
LoginDate DATETIME

What would happen if the user changes his/her email address? The answer, NOTHING.

What I think you are suggesting is the following:

User:
UserID INT IDENTITY(1,1) PK
UserName varchar(50)
UserEmailAddress varchar(255) UNIQUE (this is the max size of an SMTP email address)

LoginData:
LoginID INT IDENTITY(1,1) PK
UserEmailAddress varchar(255) FK to User
LoginDate DATETIME

Now if the email address changes, you need to change every record in LoginData AND you have violated normalization rules by duplicating USER DATA (UserEmailAddress) in your tables. Also, you have made your table linking take 10,000 times longer to search by using a varchar(255) rather than the int.

|||Now, lets further complicate your issue by talking about adding some way to find "Last Login Date".

Normalization would say, you have it:

SELECT MAX(LoginData.LoginDate) FROM LoginData WHERE LoginID=@.LoginID

However, it is a terrible waste of time to scan 1 billion records.

FYI, in MS SQL (but no other engine) you could do:

SELECT TOP 1 LoginData.LoginDate FROM LoginData WHERE LoginID=@.LoginID ORDER BY LoginData.LoginDate DESC

So most people would just add "LastLoginDate datetime" to User and update it when the user logged in.

Yes, it violates normalization rules, but one field is nothing. Then it is 2, then 10, then 100 and then normalization is out the window. Smile

|||

Tom Phillips wrote:

They are not the "same thing". They are used for different purposes. The ONLY thing the same is they are both unique. They are not redundant.

You NEVER, EVER link tables on a user changeable data. In the MS example, I assume, "NationalID" is a user entered field (probably Social Security Number). Although, it needs to be unique, because 2 people cannot have the same number, the user MIGHT change it for many reasons (it was entered wrong or changed for some other reason). Therefore, you do not link tables on the NationalID field. You use the EmployeeID field, which is also unique, but NEVER changes after it is created by the software.

<skip>
Now if the email address changes, you need to change every record in LoginData AND you have violated normalization rules by duplicating USER DATA (UserEmailAddress) in your tables. Also, you have made your table linking take 10,000 times longer to search by using a varchar(255) rather than the int.

The fact that changing primary key (like object address in a program) is problematic does not mean that adding an extra reference you do no incur a redundancy.

Arnie Rowland wrote:

Valentin,

There are times when it is necessary to handle what you classsify as 'redundancy'. For example, in the USA, it is necessary to have an Employees TaxID number stored and available for government related reports and tax filings. However, that is 'protected' and sensitive data, and therefor 'should' NOT be used as a Primary Key for normal reports and operations. And we don't have 'mandated' NationalID number -yet.

But I'm addressing the case when the symbolic name is unique and mandatory. In our app, user logs in by email. In this case, email is not just unique. Since it is used to uniquely identify users, it is a key (nulls are not allowed). The int ID uses the same purpose. It duplicates the email field. The same situations I have in 'groups' table where human-manageable groups must have unique names but we refer the groups by ID. In addition to being redundant, the design overcomplicates the things because user normally wants to see the group (s)he belongs in text rather than an integer id of the group.

Though, the keys are duplicated, I cannot bring an inconsistency example, which proves the redundancy. But 3rd normal form requires the record fields to depend only on the primary key. Meantime, users in my database are identified/refered/addressed/pointed to by email. It is a natural primary key. Integer IDs were artificially introduced to do the same job.

character encoding problem

I'm storing data in SQL Server 2005 Express ntext fields. I've added <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> to the Master Page, but apostrophes and other characters are appearing incorrectly in the browser. For example, apostrophes are appearing as?. They seem to have changed to this when I upsized from Access to SQL Server (so I have? in the db field).

The back-end of the site is still in classic asp, where I can set the CodePage to 65001 and the CharSet to utf-8, and everything appears fine there. What can I change in the ASPX to get characters to display correctly?

Apostrophes in SQL Server falls under ANSI SQL 92 delimiters you have to take care of that in SQL Server and other characters fall under collation so it will help if you check both to see where the problem is coming from. The aspx pages falls under encoding in VS2005 you can use the advanced option to choose the editor to use to save your code that includes the code page and encoding. The links below will help you with delimiter and page level encoding in .NET. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms176027.aspx
http://www.yoda.arachsys.com/csharp/strings.html


|||

This conversion of apostrophes and other characters such as dashes took place when I used the upsizing wizard in Access. I thought the classic asp pages were somehow converting them and displaying them correctly. I was wrong - I had forgotten to change the connection string, so they were still connecting to the old Access dbEmbarrassed

For the sake of speed, I cobbled together a little VBScript and ran it against the SQL Server db to perform a quick find and replace.

|||So you have fixed the problem? if not let me know so we can find what needs to be fixed.

Sunday, February 12, 2012

Char Fields Everywhere!

Hi,
We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are used
every. Varchar fields are NOT used. Is there any specific reason for it. Can
someone through some light on this subject. I am just curious.
Thanks in advance.
--SeequellWhoever wrote the app doesn't know what they're doing?
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
> Hi,
> We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
> used
> every. Varchar fields are NOT used. Is there any specific reason for it.
> Can
> someone through some light on this subject. I am just curious.
> Thanks in advance.
> --Seequell|||I would like to explore more before coming to that conclusion...
--Seequell
"Adam Machanic" wrote:
> Whoever wrote the app doesn't know what they're doing?
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.datamanipulation.net
> --
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
> > Hi,
> > We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
> > used
> > every. Varchar fields are NOT used. Is there any specific reason for it.
> > Can
> > someone through some light on this subject. I am just curious.
> > Thanks in advance.
> > --Seequell
>
>|||JDEdwards is the same way (at least the one place I've been that used it
was...)
Perhaps a leftover from an application that was ported from yesteryear, when
varchars were not allowed, or form a different platform (mainframe?)
Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
--
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...
>I would like to explore more before coming to that conclusion...
> --Seequell
>
> "Adam Machanic" wrote:
>> Whoever wrote the app doesn't know what they're doing?
>>
>> --
>> Adam Machanic
>> SQL Server MVP
>> http://www.datamanipulation.net
>> --
>>
>> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
>> news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
>> > Hi,
>> > We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
>> > used
>> > every. Varchar fields are NOT used. Is there any specific reason for
>> > it.
>> > Can
>> > someone through some light on this subject. I am just curious.
>> > Thanks in advance.
>> > --Seequell
>>|||I am not familiar with mainframe...
Is varchar field is not allowed in mainframe?
Thanks.
--Seequell
"Kevin3NF" wrote:
> JDEdwards is the same way (at least the one place I've been that used it
> was...)
> Perhaps a leftover from an application that was ported from yesteryear, when
> varchars were not allowed, or form a different platform (mainframe?)
> Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...
> >I would like to explore more before coming to that conclusion...
> >
> > --Seequell
> >
> >
> > "Adam Machanic" wrote:
> >
> >> Whoever wrote the app doesn't know what they're doing?
> >>
> >>
> >> --
> >> Adam Machanic
> >> SQL Server MVP
> >> http://www.datamanipulation.net
> >> --
> >>
> >>
> >> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> >> news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
> >> > Hi,
> >> > We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
> >> > used
> >> > every. Varchar fields are NOT used. Is there any specific reason for
> >> > it.
> >> > Can
> >> > someone through some light on this subject. I am just curious.
> >> > Thanks in advance.
> >> > --Seequell
> >>
> >>
> >>
>
>

Char Fields Everywhere!

Hi,
We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are used
every. Varchar fields are NOT used. Is there any specific reason for it. Can
someone through some light on this subject. I am just curious.
Thanks in advance.
--SeequellWhoever wrote the app doesn't know what they're doing?
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
> Hi,
> We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
> used
> every. Varchar fields are NOT used. Is there any specific reason for it.
> Can
> someone through some light on this subject. I am just curious.
> Thanks in advance.
> --Seequell|||I would like to explore more before coming to that conclusion...
--Seequell
"Adam Machanic" wrote:

> Whoever wrote the app doesn't know what they're doing?
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.datamanipulation.net
> --
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
>
>|||JDEdwards is the same way (at least the one place I've been that used it
was...)
Perhaps a leftover from an application that was ported from yesteryear, when
varchars were not allowed, or form a different platform (mainframe?)
Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...[vbcol=seagreen]
>I would like to explore more before coming to that conclusion...
> --Seequell
>
> "Adam Machanic" wrote:
>|||I am not familiar with mainframe...
Is varchar field is not allowed in mainframe?
Thanks.
--Seequell
"Kevin3NF" wrote:

> JDEdwards is the same way (at least the one place I've been that used it
> was...)
> Perhaps a leftover from an application that was ported from yesteryear, wh
en
> varchars were not allowed, or form a different platform (mainframe?)
> Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...
>
>

Char Fields Everywhere!

Hi,
We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are used
every. Varchar fields are NOT used. Is there any specific reason for it. Can
someone through some light on this subject. I am just curious.
Thanks in advance.
--Seequell
Whoever wrote the app doesn't know what they're doing?
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
> Hi,
> We are using Oracle/PeopleSoft CRM on SQL2K. I see only char fields are
> used
> every. Varchar fields are NOT used. Is there any specific reason for it.
> Can
> someone through some light on this subject. I am just curious.
> Thanks in advance.
> --Seequell
|||I would like to explore more before coming to that conclusion...
--Seequell
"Adam Machanic" wrote:

> Whoever wrote the app doesn't know what they're doing?
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.datamanipulation.net
> --
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A97D507B-7E93-4F17-8FC6-49E4700DE752@.microsoft.com...
>
>
|||JDEdwards is the same way (at least the one place I've been that used it
was...)
Perhaps a leftover from an application that was ported from yesteryear, when
varchars were not allowed, or form a different platform (mainframe?)
Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Seequell" <Seequell@.discussions.microsoft.com> wrote in message
news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...[vbcol=seagreen]
>I would like to explore more before coming to that conclusion...
> --Seequell
>
> "Adam Machanic" wrote:
|||I am not familiar with mainframe...
Is varchar field is not allowed in mainframe?
Thanks.
--Seequell
"Kevin3NF" wrote:

> JDEdwards is the same way (at least the one place I've been that used it
> was...)
> Perhaps a leftover from an application that was ported from yesteryear, when
> varchars were not allowed, or form a different platform (mainframe?)
> Unfortunately, I;m not familiar with the history of PeopleSoft CRM...
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "Seequell" <Seequell@.discussions.microsoft.com> wrote in message
> news:A3348B42-5AB1-473C-80E7-634DD96D663C@.microsoft.com...
>
>

Friday, February 10, 2012

Changing the value of the Database Field?

Hi all,

I'm working on Crystal reports in VS2005.

My database fields got the values in integer format whereas I want to display some string instead.
for example... if the database field value is 0, I must display "No Value" and for 1, "Low", for 2, "High".... so on!

I've been trying this using formula fields. But I couldn't get the correct results. the text of the formula fields is not varying according to the database field value.

So, how can I display a value based on the database field value instead of the database field value itself??

Pls help me solving this prob out!

Thank you.What do you currently have as your formula?
Also, look at the help for 'case' or 'switch'.|||Actually, select expressions are more what you're after, like

Select {table.field}
Case 0:
'No Value'
Case 1:
'Low'
Case 2:
'High'
...and so on
default: 'Unknown!';|||I dont know if this works out in your case but you can give a try
right click and select format field
click on the formula editor for suppress
write the formula
if
{dbfield i.e your field} = o then no value else if

{dbfield i.e your field} = 1 then low value else if

{dbfield i.e your field} = 2 then high value.

should work

do reply if it works...
regards|||I dont know if this works out in your case but you can give a try
right click and select format field
click on the formula editor for suppress
write the formula
if
{dbfield i.e your field} = o then no value else if

{dbfield i.e your field} = 1 then low value else if

{dbfield i.e your field} = 2 then high value.

should work

do reply if it works...
regards

Hi...

It worked out, but not with the exact format! I used UnboundString Field and inserted a formula in it for every Database field in my table. My formula contains something similar to what you've suggested!

Any way... I got the result in time and thank you very much for the reply!!