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

Friday, March 23, 2012

Failed to enable constraints


Hello there,

I have a table under SQL2005 express with 8 fields with a primaryKey defined.

In my BLL in the table adapter there is one "SELECT DISTINCT prodCAT from prods"

The prodCAT is a nvarchar(50) and it is not part of an index or primaryKey.

When I preview the data from my BLL I get the correct data.

I defined a new web form (aspx) and put a ddl (dropDownList) with an objectdataSource that relates to the above sql function/command

and I get a

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

BTW when I defined the above SQL in the BLL I got a "The new command text makes the function return data with schema different from the schema of the main query"

Any suggestions?Huh?

Does your BLL return a dataset? If so you shoudl not get the behaviour described.|||

yes, it should return a dataset.

|||

sorry,

it return a data table

|||Try changing it to return a dataset.|||How do I do that??|||Look athttp://www.dotnetjunkies.com/QuickStartv20/howto/doc/adoplus/GetDataFromDB.aspx ADO.NET: Populate a DataSet from a Database|||

Smile

First thanx a lot

If I populate the dataset using this technique by-pass the BLL. Is it the correct way to do things??

best regards

|||There are times when a Business Logic Layer is useful - this does not look like one! You could of course put an entry into the BLL that calls the layer below to get a dataset and pass it up to the GUI.

Wednesday, March 7, 2012

fact or dimension table

Hi
How does one decide if data should go into a fact or dimension table?
I have 1 primary key and lots of textual information (5 fields) which
suggests dimension.
However, the data is extremely unlikely to change, which suggets fact'
AntNeither of these suggests "fact" vs. "dimension".
A fact is a record of something that occurred -- a sales transaction, for
instance, is a fact. A dimension is information that can be used to
identify the fact -- when it occurred, who was involved, etc.
Facts and dimensions are decided based on the logical context of the data,
not on the basis of when or how the data operates.
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"-ants-" <ants@.inurpants.com> wrote in message
news:T9udnVc4pNyZl8DZRVny1g@.pipex.net...
> Hi
> How does one decide if data should go into a fact or dimension table?
> I have 1 primary key and lots of textual information (5 fields) which
> suggests dimension.
> However, the data is extremely unlikely to change, which suggets fact'
>
> Ant
>|||"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:us8kK6UcGHA.3344@.TK2MSFTNGP03.phx.gbl...
> Neither of these suggests "fact" vs. "dimension".
Hi
could we talk about this via private email please? Is your email address
valid?
Ant|||I would be happy to dicuss this with you privately, but please keep in mind
that I consider private help to be a type of consulting service, so we'll
have to work out contractual terms first. If you'd like to proceed with
that, you can e-mail me at the e-mail address I've used here, minus
"_removetoemail_".
Otherwise, we can keep discussing here in the public group.
Also, you might want to read this book, which someone recently posted a link
to here:
http://www.redbooks.ibm.com/abstrac...47138.html?Open
It is a free book from IBM on dimensional modeling. I flipped through it
and it seems like a great intro text (especially given its price!
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"-ants-" <ants@.inurpants.com> wrote in message
news:jt2dnek5tKugk8DZRVnyvQ@.pipex.net...
> "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> news:us8kK6UcGHA.3344@.TK2MSFTNGP03.phx.gbl...
> Hi
> could we talk about this via private email please? Is your email address
> valid?
> Ant
>

Sunday, February 26, 2012

fabricated hierarchical recordset

I want to use fabricated hierarchical recordset in VB6 using ADO. I wrote
code like
dim rs as adodb.recordest
set rs=new adodb.recordest
rs.fields.append "a1",adChar,30
Then in loop I put
rs.addnew
rs("a1")=...
re.update
when I associated this with hierarchical flexgrid I saw what I expected. On
the next step I added line
rs.fields.append "a2",adChapter
and this operator gave me error that I use wrong parms. Then I realized that
I should use specific connection. But with this connection adChar stopped to
work also. Is it possible to resolve this problem?
--
Aleks Kleyn
http://www.geocities.com/aleks_kleynHi Alex,

check next KB about how to create hierarchical recordset programmatically

http://support.microsoft.com/defaul...kb;en-us;196029

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp

"ALEX KLEIN" <alekskleyn@.optonline.net> wrote in message
news:Vip2b.193279$_R5.71553770@.news4.srv.hcvlny.cv .net...
> I want to use fabricated hierarchical recordset in VB6 using ADO. I wrote
> code like
> dim rs as adodb.recordest
> set rs=new adodb.recordest
> rs.fields.append "a1",adChar,30
> Then in loop I put
> rs.addnew
> rs("a1")=...
> re.update
> when I associated this with hierarchical flexgrid I saw what I expected.
On
> the next step I added line
> rs.fields.append "a2",adChapter
> and this operator gave me error that I use wrong parms. Then I realized
that
> I should use specific connection. But with this connection adChar stopped
to
> work also. Is it possible to resolve this problem?
> --
> Aleks Kleyn
> http://www.geocities.com/aleks_kleyn

Extremely slow runtime running SSRS on a cube

Hi everyone:

I am developing an SSRS report over a cube. When I drag and drop fields, it works fine. it runs in a few minutes. I am selectinng only from a single day - about 10,000 records. However, when I add some calculated fields it takes much longer. It's been running for 7 hours. The calculated fields fields are pretty simple. Some are selection of one field over another depending upon the value of a 3rd field. One is two fields multiplied together. One is a constant times a field. Something's obviously wrong here. Anybody seen this or have a solution?

Barry

If you use the MDX query designer (the GUI) in SSRS, I believe it puts the NON EMPTY keyword on both axes. So as soon as you put calculated measures into the query, it now has to do a non-empty against the calculation. This is MUCH more expensive unless you've properly defined a NON_EMPTY_BEHAVIOR.

Option 1: Do a search for NON_EMPTY_BEHAVIOR and add that to all your calculated measures.

Option 2: Flip over to the advanced tab where you can manually control the MDX query and start using the NonEmpty function instead of the NON EMPTY keyword. If you use the NonEmpty function, then you can specify which (physical) measure it should check.

That make sense?

|||

Thanks so much! That worked like a charm.

I am new to MDX, been using Oracle and am pretty helpless without the query builder.

|||

Well, it ran pretty fast, but my calculated field disappears when I switch to design mode. Here's what the qury looks like:

WITH MEMBER [Measures].[Fill Price]

AS 'IIF( [Dim Trade Info].[Hold Type]="CASH", [Dim TradeId].[Spot 3 Month], [Dim TradeId].[Price All In] )'

SELECT NONEMPTY ( { [Measures].[Slippage Tick Open Price], [Measures].[Slippage Open Price], [Measures].[Slippage G1 Bank], [Measures].[Quantity], [Measures].[Slippage Contract Open Price], [Measures].[Fill Price], [Measures].[Slippage Contract TWAP], [Measures].[Slippage Tick TWAP], [Measures].[Slippage TWAP], [Measures].[Slippage G1 Model] } )

ON COLUMNS, NONEMPTY ( { ([Fill Date].[Full Date].[Full Date].ALLMEMBERS * [Dim Team].[Team].[Team].ALLMEMBERS * [Dim Trader].[Trader Name].[Trader Name].ALLMEMBERS * [Dim Trade Info].[Hold Type].[Hold Type].ALLMEMBERS * [Dim Model].[Model Name].[Model Name].ALLMEMBERS * [Dim Market].[Report Name].[Report Name].ALLMEMBERS * [Dim TradeId].[Direction].[Direction].ALLMEMBERS * [Dim TradeId].[Spot 3 Month].[Spot 3 Month].ALLMEMBERS * [Dim TradeId].[Price All In].[Price All In].ALLMEMBERS * [Dim TradeId].[Open Price].[Open Price].ALLMEMBERS * [Dim TradeId].[TWAP].[TWAP].ALLMEMBERS ) } )

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Fill Date].[Full Date].&[2007-08-08T00:00:00] : [Fill Date].[Full Date].&[2007-08-09T00:00:00] ) ON COLUMNS FROM [Trade]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

The part referenced by 'IIF( [Dim Trade Info].[Hold Type]="CASH", [Dim TradeId].[Spot 3 Month], [Dim TradeId].[Price All In] )' Is what I want to select. It disappeared, though.

Barry

Extremely slow runtime running SSRS on a cube

Hi everyone:

I am developing an SSRS report over a cube. When I drag and drop fields, it works fine. it runs in a few minutes. I am selectinng only from a single day - about 10,000 records. However, when I add some calculated fields it takes much longer. It's been running for 7 hours. The calculated fields fields are pretty simple. Some are selection of one field over another depending upon the value of a 3rd field. One is two fields multiplied together. One is a constant times a field. Something's obviously wrong here. Anybody seen this or have a solution?

Barry

If you use the MDX query designer (the GUI) in SSRS, I believe it puts the NON EMPTY keyword on both axes. So as soon as you put calculated measures into the query, it now has to do a non-empty against the calculation. This is MUCH more expensive unless you've properly defined a NON_EMPTY_BEHAVIOR.

Option 1: Do a search for NON_EMPTY_BEHAVIOR and add that to all your calculated measures.

Option 2: Flip over to the advanced tab where you can manually control the MDX query and start using the NonEmpty function instead of the NON EMPTY keyword. If you use the NonEmpty function, then you can specify which (physical) measure it should check.

That make sense?

|||

Thanks so much! That worked like a charm.

I am new to MDX, been using Oracle and am pretty helpless without the query builder.

|||

Well, it ran pretty fast, but my calculated field disappears when I switch to design mode. Here's what the qury looks like:

WITH MEMBER [Measures].[Fill Price]

AS 'IIF( [Dim Trade Info].[Hold Type]="CASH", [Dim TradeId].[Spot 3 Month], [Dim TradeId].[Price All In] )'

SELECT NONEMPTY ( { [Measures].[Slippage Tick Open Price], [Measures].[Slippage Open Price], [Measures].[Slippage G1 Bank], [Measures].[Quantity], [Measures].[Slippage Contract Open Price], [Measures].[Fill Price], [Measures].[Slippage Contract TWAP], [Measures].[Slippage Tick TWAP], [Measures].[Slippage TWAP], [Measures].[Slippage G1 Model] } )

ON COLUMNS, NONEMPTY ( { ([Fill Date].[Full Date].[Full Date].ALLMEMBERS * [Dim Team].[Team].[Team].ALLMEMBERS * [Dim Trader].[Trader Name].[Trader Name].ALLMEMBERS * [Dim Trade Info].[Hold Type].[Hold Type].ALLMEMBERS * [Dim Model].[Model Name].[Model Name].ALLMEMBERS * [Dim Market].[Report Name].[Report Name].ALLMEMBERS * [Dim TradeId].[Direction].[Direction].ALLMEMBERS * [Dim TradeId].[Spot 3 Month].[Spot 3 Month].ALLMEMBERS * [Dim TradeId].[Price All In].[Price All In].ALLMEMBERS * [Dim TradeId].[Open Price].[Open Price].ALLMEMBERS * [Dim TradeId].[TWAP].[TWAP].ALLMEMBERS ) } )

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Fill Date].[Full Date].&[2007-08-08T00:00:00] : [Fill Date].[Full Date].&[2007-08-09T00:00:00] ) ON COLUMNS FROM [Trade]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

The part referenced by 'IIF( [Dim Trade Info].[Hold Type]="CASH", [Dim TradeId].[Spot 3 Month], [Dim TradeId].[Price All In] )' Is what I want to select. It disappeared, though.

Barry

Friday, February 24, 2012

Extracting the duplicates using Fuzzy Grouping

Hi,

I have an Oracle table called "Party" which contains Party_Id as primary key and have Party_Name, Party_Addr etc., as fields. We have lot more duplicate party details such as (party_name and party_addr) in this table. We are trying to aviod duplicates using FUZZY logic of SSIS.

1. Is any body suggest me how to create package to avoid duplicates using Fuzzy logic for this scenario(Step by step instructions are good for me to understand SSIS).

2. Could you please provide me some samples for FUZZY(Please send me a sample to my email)

Ever heard of Google? http://www.google.ie/search?hl=en&q=ssis+fuzzy&meta=

Emailing defeats the object of having online forums and it is far easier for people to reply here than to send an email. Perhaps you could do the legwork yourself instead of asking people to do it for you?

-Jamie

Sunday, February 19, 2012

Extracting SQL fields from XML Data stored in NText field

I have a interesting situation, where XML is stored inside of SQL NText
field.
Unfortunately, I need to extract that data as SQL from the XML.
Here is the data in the BillingAddress field:
<?xml version="1.0" encoding="utf-16"?>
<Address>
<ID>-1</ID>
<FirstName>Joe</FirstName>
<LastName>McLean</LastName>
<StreeLine1>360 E Columbia 48</StreeLine1>
<City>Emerson</City>
<StateName>Arkansas</StateName>
<StateCode>4</StateCode>
<PostalCode>71740</PostalCode>
<CountryName>United States</CountryName>
<CountryCode>en-US</CountryCode>
<PhoneNumber>870-547-2251</PhoneNumber>
</Address>
I need to be able to have a SQL query that returns all of those nodes
(FirstName, LastName, etc) as individual SQL fields.
Can this be done?
Thanks in advance!
Robert Johnson
Internet Web ZoneHave you looked in to using OPENXML? SQL Server Books Online has tons of
information and examples on this. Also, check out www.sqlxml.org
Anith|||I spent hours looking. That is why I posted the question. If you don't have
an answer, please don't respond.
Robert
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:%23DNdh8yAFHA.3376@.TK2MSFTNGP12.phx.gbl...
> Have you looked in to using OPENXML? SQL Server Books Online has tons of
> information and examples on this. Also, check out www.sqlxml.org
> --
> Anith
>|||Here is an example:
CREATE TABLE t (
keycol INT NOT NULL PRIMARY KEY,
xmlval NTEXT )
INSERT t SELECT 1,
'<Address>
<ID>-1</ID>
<FirstName>Joe</FirstName>
<LastName>McLean</LastName>
<StreeLine1>360 E Columbia 48</StreeLine1>
<City>Emerson</City>
<StateName>Arkansas</StateName>
<StateCode>4</StateCode>
<PostalCode>71740</PostalCode>
<CountryName>United States</CountryName>
<CountryCode>en-US</CountryCode>
<PhoneNumber>870-547-2251</PhoneNumber>
</Address>'
DECLARE @.xml VARCHAR(8000), @.idoc INT
SET @.xml = ( SELECT CAST( xmlval AS VARCHAR(8000 ) )
FROM t WHERE keycol = 1 )
EXEC sp_xml_preparedocument @.idoc OUTPUT, @.xml
SELECT *
FROM OPENXML ( @.idoc, '/Address', 2 )
WITH ( FirstName VARCHAR(20),
LastName VARCHAR(20) )
EXEC sp_xml_removedocument @.idoc
Anith|||There is no need to be rude. Where does it say in your original post that
you " ... spent hours looking ..."? And specifically, where does it say that
you spent hours looking at the topics in BOL about OpenXML? Or browsing
through the excellent resource at sqlxml.org?
All we know is what we see in your post. Don't expect us to be able to
somehow be aware of all the research that you've already done before posting
your question.
Ah, I see that Anith was gracious enough to overlook your rudeness and post
an example. Good for Anith.
Bob Barrows
Robert Johnson wrote:
> I spent hours looking. That is why I posted the question. If you
> don't have an answer, please don't respond.
> Robert
>
> "Anith Sen" <anith@.bizdatasolutions.com> wrote in message
> news:%23DNdh8yAFHA.3376@.TK2MSFTNGP12.phx.gbl...
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Extracting multiple values as comma seperated

Hi all,

This is my table :

WorkstationNo UserID

101 a1

102 a2

103 a3

101 a2

and there are many other fields too. The output I need is something like this

WorsktationNo OccupiedBy

101 a1,a2

102 a2

103 a3

In the similar fashion I would also require to retrieve the values based on the UserID something like this

UserID Workstations

a1 101

a2 101,102

a3 103

Could someone tell me how to write the query for this.

Here ya go

Code Snippet

create table #t (WorkstationNo int, UserID varchar(10) )

insert into #t

select 101, 'a1'

union all select 102, 'a2'

union all select 103, 'a3'

union all select 101, 'a2'

select WorkstationNo,

substring( ( SELECT ', ' + UserID AS [text()]

FROM #t t2

WHERE t1.WorkstationNo = t2.WorkstationNo

FOR XML path(''), elements ), 2, 1000) as OccupiedBy

from #t t1

group by WorkstationNo

select UserID,

substring( ( SELECT ', ' + convert( varchar(10), WorkstationNo ) AS [text()]

FROM #t t2

WHERE t1.UserID = t2.UserID

FOR XML path(''), elements ), 2, 1000) as OccupiedBy

from #t t1

group by UserID

|||

Thanks DaleJ..

worked like a charm. I guess i will take time to understand the code...

Friday, February 17, 2012

Extracting and converting text fields.

Hi All
I have a bug where a text field is saving text to a limit of 256 characters,
which is no where near enough. The table structure is an ID with an
identity Int, and a field called responseText.
I cannot run an alter table as "alter table tempresponses alter column
responsetext varchar(5000)"
Because "Cannot alter column 'responsetext' because it is 'text'."
I have tried to add a temporary column, but this makes it worse:
Alter table tempresponses add temp_column varchar(5000) --Add temp
column
update tempresponses set temp_column = cast(ResponseText as varchar) --
Fill out. Size irrelevant as is max 256 currently
alter table tempresponses drop column ResponseText -- Drop the TEXT
alter table tempresponses add ResponseText varchar (5000) -- read as
varchar
update tempresponses set ResponseText=temp_column
alter table tempresponses drop column temp_column
But this doesn't seem to work because it promptly crops the data at 30 chars
on doing the cast. I cannot see why. I got this solution from the
Microsoft Online Books.
Is there anything else I can try?
I have two tables that are doing this currently, and people are going to be
losing data if I cant figure this out. Shutting the database down is about
my only option at this stage.
Help.
Many Thanks
Ashley> I have a bug where a text field is saving text to a limit of 256
> characters,
Are you sure that is all that is being saved? Or are you relying on Query
Analyzer in its default configuration and counting the characters that it
returns? Try SELECT DATALENGTH(column) to see if the length really is
255/256.
This is a very common symptom and *almost always* it is a mis-diagnosis
because of http://www.aspfaq.com/2272.
If the data really isn't getting into the table, then it is usually either a
stored procedure @.param declaration issue, where the defined size is
VARCHAR(x), or a problem in the application that is generating the call to
do the insert.|||Yeah - the stored procedure that initially padded the table was varchar so I
fixed that instead. I did wonder for a while if it was Query Analyser.
The mis-diagnosis info was very useful and I have put into a FAQ db that I
use for my own references. Sweet, thanks
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uQX11p8kFHA.4000@.TK2MSFTNGP12.phx.gbl...
> Are you sure that is all that is being saved? Or are you relying on Query
> Analyzer in its default configuration and counting the characters that it
> returns? Try SELECT DATALENGTH(column) to see if the length really is
> 255/256.
> This is a very common symptom and *almost always* it is a mis-diagnosis
> because of http://www.aspfaq.com/2272.
> If the data really isn't getting into the table, then it is usually either
> a stored procedure @.param declaration issue, where the defined size is
> VARCHAR(x), or a problem in the application that is generating the call to
> do the insert.
>|||On Fri, 29 Jul 2005 11:04:37 +1200, "amb" <@.> wrote:
(snip)
Hi Ashley,
Aaron already replied to your main question, but he didn't comment on
this part:

>update tempresponses set temp_column = cast(ResponseText as varchar) --
(snip)
>But this doesn't seem to work because it promptly crops the data at 30 char
s
>on doing the cast. I cannot see why.
If varchar (or char) is specified without length, it will in most cases
default to a length of 1 character. The only exception is in a CAST
function: for reasons beyond me, the default is set to 30 characters in
this context.
That's why the statement above crops your data to 30 characters.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)