Showing posts with label based. Show all posts
Showing posts with label based. Show all posts

Monday, March 26, 2012

Failed to generate a user instance of SQL Server

Hello all,

I have a VB.NET 2005 windows based application that uses the Enterprise Library Data Access Application Block and SQL Server Express and I am having an issue getting the application to install and run from a Setup Package.

I have included the Prerequisites of SQL Server Express, .NET Framework and Microsoft Visual Studio 2005 Report Viewer in my setup project and when I run setup.exe that was created by my Setup Project, it appears everything is installed correctly on the client pc. However, when I go to run the application if get the following error:

10/05 08:44:35 ERROR DHGUI.DHConfiguration DHConfiguration_FormClosed
System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoLoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(CommandType commandType, String commandText, DataSet dataSet, String[] tableNames)
at DHFramework.Configuration.GetConfigDS()
at DHFramework.Links.InitializeLinks()
at DHGUI.DHConfiguration.DHConfiguration_FormClosed(Object sender, FormClosedEventArgs e)

I ran the SSEUTIL program with the -l option and it returns the message of:
Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Can anyone please tell me what it is that I'm doing wrong and how I can get this to work? I'm up against a deadline and this is killing me!

Thanks,

Brent

There appears to be something that SQL Express doesn't like when being installed via a Remote Desktop connection. So I re-installed my application without using Remote Desktop and that seems to have cleared it up.

Brent

|||

Bsmith05 wrote:

I have included the Prerequisites of SQL Server Express, .NET Framework and Microsoft Visual Studio 2005 Report Viewer in my setup project and when I run setup.exe that was created by my Setup Project, it appears everything is installed correctly on the client pc.

how did you do? can you explain this to me, please?

|||If you're referring to how I included the prerequisites, right-click on your project in the Solution Explorer, click on the Publish tab and then you will see a button called Prerequisites. If you click that you will see a list of available Prerequisites. If you select any one of those they will be included in the installation package and they will be installed on the target machine during the setup process.

Hope that helps.

Failed to generate a user instance of SQL Server

Hello all,

I have a VB.NET 2005 windows based application that uses the Enterprise Library Data Access Application Block and SQL Server Express and I am having an issue getting the application to install and run from a Setup Package.

I have included the Prerequisites of SQL Server Express, .NET Framework and Microsoft Visual Studio 2005 Report Viewer in my setup project and when I run setup.exe that was created by my Setup Project, it appears everything is installed correctly on the client pc. However, when I go to run the application if get the following error:

10/05 08:44:35 ERROR DHGUI.DHConfiguration DHConfiguration_FormClosed
System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoLoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(CommandType commandType, String commandText, DataSet dataSet, String[] tableNames)
at DHFramework.Configuration.GetConfigDS()
at DHFramework.Links.InitializeLinks()
at DHGUI.DHConfiguration.DHConfiguration_FormClosed(Object sender, FormClosedEventArgs e)

I ran the SSEUTIL program with the -l option and it returns the message of:
Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Can anyone please tell me what it is that I'm doing wrong and how I can get this to work? I'm up against a deadline and this is killing me!

Thanks,

Brent

There appears to be something that SQL Express doesn't like when being installed via a Remote Desktop connection. So I re-installed my application without using Remote Desktop and that seems to have cleared it up.

Brent

|||

Bsmith05 wrote:

I have included the Prerequisites of SQL Server Express, .NET Framework and Microsoft Visual Studio 2005 Report Viewer in my setup project and when I run setup.exe that was created by my Setup Project, it appears everything is installed correctly on the client pc.

how did you do? can you explain this to me, please?

|||If you're referring to how I included the prerequisites, right-click on your project in the Solution Explorer, click on the Publish tab and then you will see a button called Prerequisites. If you click that you will see a list of available Prerequisites. If you select any one of those they will be included in the installation package and they will be installed on the target machine during the setup process.

Hope that helps.sql

Monday, March 19, 2012

Failed Maintenance Plan Job

Could anybody tell me why this job would be failing based on this log?
Running SQL 2000 SP4.
Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL
Server 'servername' as 'domain\username' (trusted)
Starting maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16
PM
Backup can not be performed on database 'axdata_live'. This sub task is
ignored.
Backup can not be performed on database 'axdata_test'. This sub task is
ignored.
Backup can not be performed on database 'Northwind'. This sub task is
ignored.
Backup can not be performed on database 'pubs'. This sub task is
ignored.
Deleting old text reports... 1 file(s) deleted.
End of maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16 PM
SQLMAINT.EXE Process Exit Code: 1 (Failed)My guess would be that those databases are in Simple recovery mode and you
are attempting to issue a Log backup. Take out the log backup and it should
work.
--
Andrew J. Kelly SQL MVP
<bjorgenson@.charter.net> wrote in message
news:1146001380.696610.165740@.g10g2000cwb.googlegroups.com...
> Could anybody tell me why this job would be failing based on this log?
> Running SQL 2000 SP4.
>
> Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL
> Server 'servername' as 'domain\username' (trusted)
> Starting maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16
> PM
> Backup can not be performed on database 'axdata_live'. This sub task is
> ignored.
> Backup can not be performed on database 'axdata_test'. This sub task is
> ignored.
> Backup can not be performed on database 'Northwind'. This sub task is
> ignored.
> Backup can not be performed on database 'pubs'. This sub task is
> ignored.
> Deleting old text reports... 1 file(s) deleted.
> End of maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16 PM
> SQLMAINT.EXE Process Exit Code: 1 (Failed)
>

Failed Maintenance Plan Job

Could anybody tell me why this job would be failing based on this log?
Running SQL 2000 SP4.
Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL
Server 'servername' as 'domain\username' (trusted)
Starting maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16
PM
Backup can not be performed on database 'axdata_live'. This sub task is
ignored.
Backup can not be performed on database 'axdata_test'. This sub task is
ignored.
Backup can not be performed on database 'Northwind'. This sub task is
ignored.
Backup can not be performed on database 'pubs'. This sub task is
ignored.
Deleting old text reports... 1 file(s) deleted.
End of maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16 PM
SQLMAINT.EXE Process Exit Code: 1 (Failed)My guess would be that those databases are in Simple recovery mode and you
are attempting to issue a Log backup. Take out the log backup and it should
work.
Andrew J. Kelly SQL MVP
<bjorgenson@.charter.net> wrote in message
news:1146001380.696610.165740@.g10g2000cwb.googlegroups.com...
> Could anybody tell me why this job would be failing based on this log?
> Running SQL 2000 SP4.
>
> Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL
> Server 'servername' as 'domain\username' (trusted)
> Starting maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16
> PM
> Backup can not be performed on database 'axdata_live'. This sub task is
> ignored.
> Backup can not be performed on database 'axdata_test'. This sub task is
> ignored.
> Backup can not be performed on database 'Northwind'. This sub task is
> ignored.
> Backup can not be performed on database 'pubs'. This sub task is
> ignored.
> Deleting old text reports... 1 file(s) deleted.
> End of maintenance plan 'DB Maintenance Plan2' on 4/25/2006 4:35:16 PM
> SQLMAINT.EXE Process Exit Code: 1 (Failed)
>

Friday, March 9, 2012

Fail Execute Process Task based on batch file ERRORLEVEL?

I am new to this, but have scoured the web and not found an answer to my question...

I have an execute process task that runs a simple batch file. When this batch file completes with an ERRORLEVEL greater than 0, I would like the task to fail. I thought this simply meant setting the "FailTaskIfReturnCodeIsNotSuccessValue" property to true, and setting the SuccessValue to 0. However, this does not appear to work.

Even with a simple batch file forcing the errorcode to 1 as follows, the task still completes "successfully".

SET ERRORLEVEL = 1

Any ideas? Thanks!

have you tried using the script task instead?|||

I am not clear on how I would use the script task to accomplish this, though would welcome suggestions. Also, just for completeness sake, can anyone tell me why a batch file ERRORLEVEL has no effect on the execute process task?

Thanks!

|||

David Kreps wrote:

I am not clear on how I would use the script task to accomplish this, though would welcome suggestions.

you would need to use the System.Diagnostics.Process class within the script task.

|||

The option to fail the task if program result code is not the expected one works with batch file.

The problem is that the command

SET ERRORLEVEL = 1

creates an environment variable ERRORLEVEL, it does not actually affect the batch script error code.

D:>SET ERRORLEVEL = 1
D:>if ERRORLEVEL 1 echo 1
D:>COLOR 00
D:>if ERRORLEVEL 1 echo 1
1

(COLOR 00 is common way to actually set the error level is batch scripts).

|||Perfect. Thank you.|||

Turns out the above did not actually work. While it correctly set the ERRORLEVEL to 1, the package still registered a success. That said, I found the solution: the batch file EXIT command:

EXIT [ERRORLEVEL]

eg: EXIT 1

As the syntax implies, this exits a batch file (or, more accurately, the instance of command.exe it is running in), returning the ERRORLEVEL specified. The Execute Process Task correctly recognizes this ERRORLEVEL as the return code, and fails appropriately.

Wednesday, March 7, 2012

Factorial Permutations, Without a Cursor?

You folks always tell me to do as much as I can with set based operations and get rid of those damn cursors, so that is what I would like to do, but I can't really see any way to get around it.

What I have to do is generate all the permutations for 6 values without having any values repeated in each combination (6 factorial, 6x5x4x3x2x1=720 permutations).

Currently I have this job that takes 1-3 seconds to run.

ALTER PROCEDURE [dbo].[proc_SAHSGenComb2] AS
DECLARE @.pos1 INT
DECLARE @.pos2 INT
DECLARE @.pos3 INT
DECLARE @.pos4 INT
DECLARE @.pos5 INT
DECLARE @.pos6 INT
DECLARE @.currID INT
DECLARE @.currSort SMALLINT
DECLARE @.combID INT

DECLARE curSeq CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_WKLD
ORDER BY HUMP_CUT_ORD

OPEN curSeq
FETCH NEXT FROM curSeq INTO @.currID
SET @.currSort = 1
WHILE @.@.FETCH_STATUS = 0
BEGIN
INSERT INTO TSA_HS_SEQ (WKLD_ID, CURR_SEQ) VALUES (@.currID, @.currSort)
SET @.currSort = @.currSort + 1
FETCH NEXT FROM curSeq INTO @.currID
END
CLOSE curSeq
DEALLOCATE curSeq

SET @.combID = 1

DECLARE curPos1 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ
WHERE CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos1

FETCH NEXT FROM curPos1 INTO @.pos1
WHILE @.@.FETCH_STATUS = 0
BEGIN
DECLARE curPos2 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ WHERE WKLD_ID <> @.pos1 AND CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos2
FETCH NEXT FROM curPos2 INTO @.pos2
WHILE @.@.FETCH_STATUS = 0
BEGIN
DECLARE curPos3 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ WHERE WKLD_ID NOT IN (@.pos1,@.pos2) AND CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos3
FETCH NEXT FROM curPos3 INTO @.pos3
WHILE @.@.FETCH_STATUS = 0
BEGIN
DECLARE curPos4 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ WHERE WKLD_ID NOT IN (@.pos1,@.pos2,@.pos3) AND CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos4
FETCH NEXT FROM curPos4 INTO @.pos4
WHILE @.@.FETCH_STATUS = 0
BEGIN
DECLARE curPos5 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ WHERE WKLD_ID NOT IN (@.pos1,@.pos2,@.pos3,@.pos4) AND CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos5
FETCH NEXT FROM curPos5 INTO @.pos5
WHILE @.@.FETCH_STATUS = 0
BEGIN
DECLARE curPos6 CURSOR FAST_FORWARD FOR
SELECT WKLD_ID FROM TSA_HS_SEQ WHERE WKLD_ID NOT IN (@.pos1,@.pos2,@.pos3,@.pos4,@.pos5) AND CURR_SEQ <= 6 ORDER BY CURR_SEQ
OPEN curPos6
FETCH NEXT FROM curPos6 INTO @.pos6
WHILE @.@.FETCH_STATUS = 0
BEGIN
BEGIN TRAN t1
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos1, 1)
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos2, 2)
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos3, 3)
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos4, 4)
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos5, 5)
INSERT INTO TSA_HS_COMB2 (COMB_ID, WKLD_ID, WKLD_SEQ) VALUES (@.combID, @.pos6, 6)
COMMIT TRAN t1
SET @.combID = @.combID + 1
FETCH NEXT FROM curPos6 INTO @.pos6
END
CLOSE curPos6
DEALLOCATE curPos6
FETCH NEXT FROM curPos5 INTO @.pos5
END
CLOSE curPos5
DEALLOCATE curPos5
FETCH NEXT FROM curPos4 INTO @.pos4
END
CLOSE curPos4
DEALLOCATE curPos4
FETCH NEXT FROM curPos3 INTO @.pos3
END
CLOSE curPos3
DEALLOCATE curPos3
FETCH NEXT FROM curPos2 INTO @.pos2
END
CLOSE curPos2
DEALLOCATE curPos2
FETCH NEXT FROM curPos1 INTO @.pos1
END
CLOSE curPos1
DEALLOCATE curPos1

If anybuddy's got any bright ideas on how to retire these cursors, I would love to hear it. Oh ya, AFAIK, the explicit transactions I added don't do a damn thing as far as imrpoving performance.

Thanks again,
Carlsort of has the homeworky feel to it...

If this is for a real business application, what's it for?|||Not exactly sure what you want. True factorial, or permutations of any (up to?) six values?

Factorials are easy if you create a table of sequential values:declare @.N int
set @.N = 6

declare @.Result int
set @.Result = 1

select @.Result = @.Result * (SeqValue + 1) from SequentialNumbers where SeqValue < @.N

select @.Result|||Ya, it's a business app. It optimzes workload sequencing, answers the question "What do I do next?"

It tries all 720 permutations, giving each a score. We simply pick the one with the highest score and earliest completion time.

Carl|||The set based solution times at around 100 ms on my laptop. I'll give you a hint: five joins, and NOT IN. I'm just curious though, because this does sound a lot like homework to me too.

-PatP|||Darn! I should have refreshed the page! Ok, I used:DECLARE @.dStart DATETIME
SET @.dStart = GetDate()

CREATE TABLE #permutations (
id INT NOT NULL
CONSTRAINT XPKpermutations
PRIMARY KEY (id)
)

INSERT INTO #permutations (id)
SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION
SELECT 4 UNION SELECT 5 UNION SELECT 6

SELECT p1.id, p2.id, p3.id, p4.id, p5.id, p6.id
FROM #permutations AS p1
JOIN #permutations AS p2
ON (p2.id NOT IN (p1.id))
JOIN #permutations AS p3
ON (p3.id NOT IN (p1.id, p2.id))
JOIN #permutations AS p4
ON (p4.id NOT IN (p1.id, p2.id, p3.id))
JOIN #permutations AS p5
ON (p5.id NOT IN (p1.id, p2.id, p3.id, p4.id))
JOIN #permutations AS p6
ON (p6.id NOT IN (p1.id, p2.id, p3.id, p4.id, p5.id))
ORDER BY 1, 2, 3, 4, 5, 6

DROP TABLE #permutations

SELECT DateDiff(ms, @.dStart, GetDate())
-PatP|||I need all permutations of the 6 values, without any of the values being repeated, which is 720 combinations (6 factorial).

I didn't mean to complicate by mentioning factorials, I did it to clarify that a value can only appear once in the combination.

Not exactly sure what you want. True factorial, or permutations of any (up to?) six values?|||Geez yer gud.
Thanks Pat.
Carl
The set based solution times at around 100 ms on my laptop. I'll give you a hint: five joins, and NOT IN. I'm just curious though, because this does sound a lot like homework to me too.

-PatP|||Mine has a COMB_ID field which tells you which of the 720 combintaions you're dealing with. How would you add a field with the values 1-720?

Actually this would allow me to ditch a lot of my cursors, as many of them are simply to get an ordinal number for the record.

Thanks again,
Carl|||Ok, I'm gonna cheat on this one because I'm lazy and time constrained, but:DECLARE @.dStart DATETIME
SET @.dStart = GetDate()

CREATE TABLE #permutations (
id INT NOT NULL
CONSTRAINT XPKpermutations
PRIMARY KEY (id)
)

INSERT INTO #permutations (id)
SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION
SELECT 4 UNION SELECT 5 UNION SELECT 6

CREATE TABLE #numberem (
id INT IDENTITY
, i1 INT NOT NULL
, i2 INT NOT NULL
, i3 INT NOT NULL
, i4 INT NOT NULL
, i5 INT NOT NULL
, i6 INT NOT NULL
)

INSERT INTO #numberem (i1, i2, i3, i4, i5, i6)
SELECT p1.id, p2.id, p3.id, p4.id, p5.id, p6.id
FROM #permutations AS p1
JOIN #permutations AS p2
ON (p2.id NOT IN (p1.id))
JOIN #permutations AS p3
ON (p3.id NOT IN (p1.id, p2.id))
JOIN #permutations AS p4
ON (p4.id NOT IN (p1.id, p2.id, p3.id))
JOIN #permutations AS p5
ON (p5.id NOT IN (p1.id, p2.id, p3.id, p4.id))
JOIN #permutations AS p6
ON (p6.id NOT IN (p1.id, p2.id, p3.id, p4.id, p5.id))
ORDER BY 1, 2, 3, 4, 5, 6

SELECT * FROM #numberem

DROP TABLE #numberem
DROP TABLE #permutations

SELECT DateDiff(ms, @.dStart, GetDate())...and it still runs in 120 ms on my laptop!

Note that there are more efficient ways to do this from an execution perspective, but I don't have the time to code them. For less than a million rows, the difference is really trivial.

-PatP|||Sweet, 200mS over the wire from Montreal. Profuse gratitude, this is one I can reuse lots.

Fact table changes

Our data mart is medical based type of subjects.
Recently; the government changed how some "hours" of service could be
provided to certain people. The "hours" value is stored in a Fact table.
So for example; Client XYZ used to have 50 hours; it may have 63 now.
So I see how easy it would have been to make these data changes if it had
been in a Dimension - would have been type 2 SCD - but not sure what best
approach is for changes in a Fact table. I'm almost tempted to have a
status column to identify which Fact record is current; but then I would
have much work to do in SSAS to change how the Cubes are put together.
What is the best practice when you have to make data changes to existing
Fact records in a dm/dw?I'd recommend avoiding changes to historic data in a DW unless they were
genuinely erroneous.
Is there a date dimension relationship in your fact table? If so, what if a
user was to pull up a report from the past where the 50 hours was correct
but your warehouse reported 63? Would this be incorrect? If there are no
dates one option as you suggest would be a flag. Then you could construct a
view selecting the same columns as before but only including current rows.
The only change you'd need to make in SSAS would be in the Data Source
View - to change from the table to the view. The disadvantage of this would
be that end-users couldn't report on the previous 'hours' value. This gets
worse if the value changes again.
A better option ('best practice' perhaps) would be to introduce a start and
end date key (related to your date dimension obviously) over which period
the value was current - perhaps seperate to any existing dates. This way end
users could query for the different hours value based on when it was
relevant. A new value generates a new row with new dates. If necessary you
could still construct a view for the most recent value - but you would still
have all of the data in the database to support more sophisticated analysis.
There's more work here clearly - only you can decide whether its worth it.
HTH
--
Phil
http://www.clarity-integration.com
http://www.phil-austin.blogspot.com
"Joe" <hortoristic@.gmail.dot.com> wrote in message
news:0CA262DF-F121-496C-878E-0CDEC387D159@.microsoft.com...
> Our data mart is medical based type of subjects.
> Recently; the government changed how some "hours" of service could be
> provided to certain people. The "hours" value is stored in a Fact table.
> So for example; Client XYZ used to have 50 hours; it may have 63 now.
> So I see how easy it would have been to make these data changes if it had
> been in a Dimension - would have been type 2 SCD - but not sure what best
> approach is for changes in a Fact table. I'm almost tempted to have a
> status column to identify which Fact record is current; but then I would
> have much work to do in SSAS to change how the Cubes are put together.
> What is the best practice when you have to make data changes to existing
> Fact records in a dm/dw?

Fact and Dimension linking

Hi,

Am a bit of a beginner in this area, so this may sound a little dumb.

I am trying to develop my first cube based on consolidated sales data from 10 different companies, and have a problem wrt linking a dimension table to this fact table.

I have a dimension table which contains the products which can be manufactured by these 10 companies. There are scenarios where one product can be made in several of these companies.

I therefore have a table with all the sales line items (my fact table) which are uniquely identified by invoice no, invoice line num, and originating site.

The product table (dimension table) is uniquely identified by item code and site.

When I create my data source view I create a join between the two tables with sales.site = products.site and sales.itemcode = products.itemcode

If I then create a dimension from my products table and browse them in the cube, the sales data just gets repeated for each product and is not correctly split.

I think that the link I have between the dimension and the fact table is wrong, as when I set the relationship I can only choose one column to link on.

I'm kinda getting lost on this one, and could really do with some pointers. Restructuring the tables are not too much of a problem (if they are wrong) as the project has not been officially released yet.

Any help would be greatly appreciated.

Hello! In the cube editor you have a dimension usage tab where you configure the relation between each dimension and measure group(fact table). If you have created som dimension after the you have created the cube this relation will not be configured automatically.

It seems to me as you relations are correct in the data source view. You can have a problem with that the product key is defined without the site key in the dimension editor. You will have to make a collection of product key and site key. Check the dimension key for this property.

HTH

Thomas Ivarsson

|||

You might check the KeyColumns property for the key attribute of your Product dimension - a composite key {item code, site} should be defined. Then you should be able to join the fact table using this composite key.

http://msdn2.microsoft.com/en-us/library/ms175461.aspx

>>

SQL Server 2005 Books Online

How to: Modify the KeyColumn Property of an Attribute

This procedure describes how to modify the KeyColumns property of an attribute. For example, you may want to specify a composite key rather than a single key as the key for the attribute.

...

>>

|||The item code and site also have to be present in the fact table for this to work. Your message says that the invoice line num is present in the fact table - you have to be able to derive the product item code from this.|||

Thx everyone... after posting I sat down and read the book again to make sure I hadn't missed anything out. And you are right, the tables are OK in my DSV, but the dimension had not been configured correctly w.r.t. its attributes.

As soon as I had that done correctly, of course it all fell into place..

Thx again.