Showing posts with label stores. Show all posts
Showing posts with label stores. Show all posts

Wednesday, March 7, 2012

Factless Fact Table

I have a table that stores all instances of when a company restates their finances. There are a number of other columns that have boolean data types in which I can use to filter. Since the records in this table are based on an event, there really isn't "fact" or numerical data.

When I build my cube in AS2005 using VS2005 and select this table as the fact table, I can't seem to get the other attributes (boolean fields) to appear as filters. Do I have to create a dimension using this table too?

For example, one report would be to display all restatements that had a negative impact (as opposed to a positive impact).

Do I have to create a dimension using this table too?


Yes (well, I guess so)
In my case I have to use it too, and I use it in a "WHERE" clause.
Kinda like:
WHERE [Blah].[True]
or something like that :-)

Friday, February 24, 2012

Extracting XML data to columns during query

I'm working with an inherited SQL 2000 database (now moved to 2005)
that stores strings of XML in a text column. I'd like to avoid
changing the schema right now. Each row's XML data looks something
like:
<root><element id='5' name='bob' message='hello' /></root>
The exact attributes in the inner element are unknown, but what I
would like to be able to do is return them as columns in a query such
that I would get:
id name message
-- -- --
5 bob hello
Any thoughts?I was just now experimenting with something similar. Most of this is right
out of the MSDN help. This is reading from an external XML file.
-- create tables for later population using OPENXML.
create table Customers (CustomerID varchar(20) primary key,
ContactName varchar(20),
CompanyName varchar(20))
go
create table Orders( CustomerID varchar(20), OrderDate datetime)
go
declare @.xmlDocument xml
select @.xmlDocument = cast (x as xml)
from OpenRowset (bulk 'P:\SQL scripts\Examples\XML\SourceOfXml.xml',
single_blob) R (x)
select @.xmlDocument
-- Contents of the source XML file.
--
-- <?xml version="1.0" encoding="windows-1252" ?>
-- <ROOT>
-- <Customers CustomerID="XYZAA" ContactName="Joe" CompanyName="Company1">
-- <Orders CustomerID="XYZAA" OrderDate="2000-08-25T00:00:00"/>
-- <Orders CustomerID="XYZAA" OrderDate="2000-10-03T00:00:00"/>
-- </Customers>
-- <Customers CustomerID="XYZBB" ContactName="Steve"
CompanyName="Company2">No Orders yet!
-- </Customers>
-- </ROOT>
declare @.docHandle int
exec sp_xml_preparedocument @.docHandle output, @.xmlDocument
-- Use OpenXML to provide rowset consisting of customer data.
insert Customers
select *
from OpenXML (@.docHandle, N'/ROOT/Customers')
with Customers
-- Use OpenXML to provide rowset consisting of order data.
insert Orders
select *
from OpenXML (@.docHandle, N'//Orders')
with Orders
-- Using OpenXML in a SELECT statement.
select *
from OpenXML (@.docHandle, N'/ROOT/Customers/Orders')
with (CustomerID nchar (5) '../@.CustomerID', OrderDate datetime)
-- Remove the internal representation of the XML document.
exec sp_xml_removedocument @.docHandle
/*
drop table Customers
drop table Orders
*/
"Brian Vallelunga" wrote:

> I'm working with an inherited SQL 2000 database (now moved to 2005)
> that stores strings of XML in a text column. I'd like to avoid
> changing the schema right now. Each row's XML data looks something
> like:
> <root><element id='5' name='bob' message='hello' /></root>
> The exact attributes in the inner element are unknown, but what I
> would like to be able to do is return them as columns in a query such
> that I would get:
> id name message
> -- -- --
> 5 bob hello
>
> Any thoughts?
>|||Hello Brian,

> I'm working with an inherited SQL 2000 database (now moved to 2005)
> that stores strings of XML in a text column. I'd like to avoid
> changing the schema right now. Each row's XML data looks something
> like:
> The exact attributes in the inner element are unknown, but what I
> would like to be able to do is return them as columns in a query such
> that I would get:
Theres lots of ways of doing this is the number of attributes are know, but
when they aren't, your going to have a hard time shaping them to a meaningfu
l
table. So whate exactly do you mean by "attributes are unknown?"
Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||On Apr 3, 11:17 pm, Kent Tegels <kteg...@.develop.com> wrote:
> Hello Brian,
>
> Theres lots of ways of doing this is the number of attributes are know, bu
t
> when they aren't, your going to have a hard time shaping them to a meaning
ful
> table. So whate exactly do you mean by "attributes are unknown?"
> Thanks!
> Kent Tegels
> DevelopMentorhttp://staff.develop.com/ktegels/
Well, the xml data holds responses to online forms. Each form may have
different fields and each form field results in a single attribute key/
value pair. If a form has a first name and last name, the attributes
for these two would show up in the XML.
Obviously this makes it a bit more difficult than if the values were
known. However, for this, we can assume that any given set of data
pulled will be for one particular form, and will thus have the same
attributes in the XML data. I may just have to do this on the client
end, but thought I'd see if a SQL method was available.

Extracting XML data to columns during query

I'm working with an inherited SQL 2000 database (now moved to 2005)
that stores strings of XML in a text column. I'd like to avoid
changing the schema right now. Each row's XML data looks something
like:
<root><element id='5' name='bob' message='hello' /></root>
The exact attributes in the inner element are unknown, but what I
would like to be able to do is return them as columns in a query such
that I would get:
id name message
-- -- --
5 bob hello
Any thoughts?
I was just now experimenting with something similar. Most of this is right
out of the MSDN help. This is reading from an external XML file.
-- create tables for later population using OPENXML.
create table Customers (CustomerID varchar(20) primary key,
ContactName varchar(20),
CompanyName varchar(20))
go
create table Orders( CustomerID varchar(20), OrderDate datetime)
go
declare @.xmlDocument xml
select @.xmlDocument = cast (x as xml)
from OpenRowset (bulk 'P:\SQL scripts\Examples\XML\SourceOfXml.xml',
single_blob) R (x)
select @.xmlDocument
-- Contents of the source XML file.
-- <?xml version="1.0" encoding="windows-1252" ?>
-- <ROOT>
-- <Customers CustomerID="XYZAA" ContactName="Joe" CompanyName="Company1">
-- <Orders CustomerID="XYZAA" OrderDate="2000-08-25T00:00:00"/>
-- <Orders CustomerID="XYZAA" OrderDate="2000-10-03T00:00:00"/>
-- </Customers>
-- <Customers CustomerID="XYZBB" ContactName="Steve"
CompanyName="Company2">No Orders yet!
-- </Customers>
-- </ROOT>
declare @.docHandle int
exec sp_xml_preparedocument @.docHandle output, @.xmlDocument
-- Use OpenXML to provide rowset consisting of customer data.
insert Customers
select *
from OpenXML (@.docHandle, N'/ROOT/Customers')
with Customers
-- Use OpenXML to provide rowset consisting of order data.
insert Orders
select *
from OpenXML (@.docHandle, N'//Orders')
with Orders
-- Using OpenXML in a SELECT statement.
select *
from OpenXML (@.docHandle, N'/ROOT/Customers/Orders')
with (CustomerID nchar (5) '../@.CustomerID', OrderDate datetime)
-- Remove the internal representation of the XML document.
exec sp_xml_removedocument @.docHandle
/*
drop table Customers
drop table Orders
*/
"Brian Vallelunga" wrote:

> I'm working with an inherited SQL 2000 database (now moved to 2005)
> that stores strings of XML in a text column. I'd like to avoid
> changing the schema right now. Each row's XML data looks something
> like:
> <root><element id='5' name='bob' message='hello' /></root>
> The exact attributes in the inner element are unknown, but what I
> would like to be able to do is return them as columns in a query such
> that I would get:
> id name message
> -- -- --
> 5 bob hello
>
> Any thoughts?
>
|||Hello Brian,

> I'm working with an inherited SQL 2000 database (now moved to 2005)
> that stores strings of XML in a text column. I'd like to avoid
> changing the schema right now. Each row's XML data looks something
> like:
> The exact attributes in the inner element are unknown, but what I
> would like to be able to do is return them as columns in a query such
> that I would get:
Theres lots of ways of doing this is the number of attributes are know, but
when they aren't, your going to have a hard time shaping them to a meaningful
table. So whate exactly do you mean by "attributes are unknown?"
Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/
|||On Apr 3, 11:17 pm, Kent Tegels <kteg...@.develop.com> wrote:
> Hello Brian,
>
> Theres lots of ways of doing this is the number of attributes are know, but
> when they aren't, your going to have a hard time shaping them to a meaningful
> table. So whate exactly do you mean by "attributes are unknown?"
> Thanks!
> Kent Tegels
> DevelopMentorhttp://staff.develop.com/ktegels/
Well, the xml data holds responses to online forms. Each form may have
different fields and each form field results in a single attribute key/
value pair. If a form has a first name and last name, the attributes
for these two would show up in the XML.
Obviously this makes it a bit more difficult than if the values were
known. However, for this, we can assume that any given set of data
pulled will be for one particular form, and will thus have the same
attributes in the XML data. I may just have to do this on the client
end, but thought I'd see if a SQL method was available.

Sunday, February 19, 2012

Extracting Latest Date

I have a db which stores all my sales transactions.
The task is to extract the buy price(price) for each item(ItemCode) where the
date is the latest for each item.
For Example:
Sales Table
ItemCode Qty Price Date
-- -- -- --
XYZ 2 23.50 12/03/05
XYZ 3 23.50 13/03/05
XYZ 2 99.99 14/03/05
ABC 14 88.88 01/01/05
RDB 12 77.30 21/04/05
RDB 23 23.35 02/05/05
I would then require only
ItemCode Qty Price Date
-- -- -- --
XYZ 2 99.99 14/03/05
ABC 14 88.88 01/01/05
RDB 23 23.35 02/05/05
How do i write a query to extract the data?
Need help with a project of mine...really stuck with this one..Thank you
On Thu, 04 Aug 2005 07:31:53 GMT, Jan S via droptable.com wrote:

>I have a db which stores all my sales transactions.
>The task is to extract the buy price(price) for each item(ItemCode) where the
>date is the latest for each item.
(snip)
>How do i write a query to extract the data?
> Need help with a project of mine...really stuck with this one..Thank you
Hi Jan,
Method #1:
SELECT a.ItemCode, a.Qty, a.Price, a.[Date]
FROM Sales AS a
WHERE NOT EXISTS
(SELECT *
FROM Sales AS b
WHERE b.ItemCode = a.ItemCode
AND b.[Date] > a.[Date])
Method #2:
SELECT a.ItemCode, a.Qty, a.Price, a.[Date]
FROM Sales AS a
WHERE a.[Date] =
(SELECT MAX(b.[Date])
FROM Sales AS b
WHERE b.ItemCode = a.ItemCode)
Method #3:
SELECT a.ItemCode, a.Qty, a.Price, a.[Date]
FROM Sales AS a
INNER JOIN (SELECT ItemCode, MAX([Date]) AS MaxDate
FROM Sales
GROUP BY ItemCode) AS b
ON b.ItemCode = a.ItemCode
AND b.MaxDate = a.[Date]
(And there might even be more methods...)
If performance is important, then test each of these queries a few times
and use the one that's the fastest. Otherwise, use the one that you find
the easiest to understand, as you'll have to maintain it later.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
|||Thanks Hugo..Much appreciated
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...-mseq/200508/1

Friday, February 17, 2012

Extracting Data from SQL CE SDF file

Hi,

I have written application for Pocket PC it stores data on SQL CE database with extension .sdf. I have added data to the table and synchronised to the SQl server. I got the data, then unfortunately i deleted the data in SQL Server, I want to extract the data again from .SDF file of Pocket PC.

Is this possible if not then how can i get the data from SDF to SQL Server

Its very urgent and waiting for early reply to following mail address
prashanthk@.mmi.ae

Regards,
Prashanththere are a couple of options Prashanth:

1. write a simple smart device program that connects to the database and table by table writes out the rows in those tables to CSV files on device. copy the CSV files to the server and import into SQL Server.

2. there are third party tools that can connect to a SQL CE .SDF file on device and query their contents. DesktopSqlCe is available for download here: http://www.primeworks.pt/

3. convert your SQL CE database to a SQL Mobile database and connect to it from Visual Studio 2005 or SQL Server 2005 Management Studio (then select out your records into another SQL Server DB).

-Darren Shaffer|||

Darren,
Can you tell me how to move an .sdf file from sql ce to sql server. I want sdf table data to append with SQL Server's existing data. Is it posible?

Thnx

Raj

|||

With SQL CE, you can't do anything with the .SDF file on your server. You need to get the data out of SQL CE while it is still on a device or emulator and transport the data (not the .SDF file) to your SQL Server. I listed the options for this - it would be very quick to simply write a program that selects out the data from SQL CE and saves it in CSV files. You can then copy the CSV files from your device to your server and then import the data into SQL Server directly from the CSV files. A third party tool like RemoteSQLCE will also handle this for you.

-Darren

|||

Darren,

Thanks a lot for your suggestions, I was looking for tools to analyse sdf databases on a Windows XP environment for a long time!

- Jeroen Boiten

|||

Hallo, I'm Gabriel and I'm working with .NET 2005 and Pocket PC 2003.

I'm very very interested of first point, the one with the CSV export.Do you have an exemple ?

I'm very time stress.

Extracting Data from SQL CE SDF file

Hi,

I have written application for Pocket PC it stores data on SQL CE database with extension .sdf. I have added data to the table and synchronised to the SQl server. I got the data, then unfortunately i deleted the data in SQL Server, I want to extract the data again from .SDF file of Pocket PC.

Is this possible if not then how can i get the data from SDF to SQL Server

Its very urgent and waiting for early reply to following mail address
prashanthk@.mmi.ae

Regards,
Prashanththere are a couple of options Prashanth:

1. write a simple smart device program that connects to the database and table by table writes out the rows in those tables to CSV files on device. copy the CSV files to the server and import into SQL Server.

2. there are third party tools that can connect to a SQL CE .SDF file on device and query their contents. DesktopSqlCe is available for download here: http://www.primeworks.pt/

3. convert your SQL CE database to a SQL Mobile database and connect to it from Visual Studio 2005 or SQL Server 2005 Management Studio (then select out your records into another SQL Server DB).

-Darren Shaffer|||

Darren,
Can you tell me how to move an .sdf file from sql ce to sql server. I want sdf table data to append with SQL Server's existing data. Is it posible?

Thnx

Raj

|||

With SQL CE, you can't do anything with the .SDF file on your server. You need to get the data out of SQL CE while it is still on a device or emulator and transport the data (not the .SDF file) to your SQL Server. I listed the options for this - it would be very quick to simply write a program that selects out the data from SQL CE and saves it in CSV files. You can then copy the CSV files from your device to your server and then import the data into SQL Server directly from the CSV files. A third party tool like RemoteSQLCE will also handle this for you.

-Darren

|||

Darren,

Thanks a lot for your suggestions, I was looking for tools to analyse sdf databases on a Windows XP environment for a long time!

- Jeroen Boiten

|||

Hallo, I'm Gabriel and I'm working with .NET 2005 and Pocket PC 2003.

I'm very very interested of first point, the one with the CSV export.Do you have an exemple ?

I'm very time stress.

Extracting Data from SQL CE SDF file

Hi,

I have written application for Pocket PC it stores data on SQL CE database with extension .sdf. I have added data to the table and synchronised to the SQl server. I got the data, then unfortunately i deleted the data in SQL Server, I want to extract the data again from .SDF file of Pocket PC.

Is this possible if not then how can i get the data from SDF to SQL Server

Its very urgent and waiting for early reply to following mail address
prashanthk@.mmi.ae

Regards,
Prashanththere are a couple of options Prashanth:

1. write a simple smart device program that connects to the database and table by table writes out the rows in those tables to CSV files on device. copy the CSV files to the server and import into SQL Server.

2. there are third party tools that can connect to a SQL CE .SDF file on device and query their contents. DesktopSqlCe is available for download here: http://www.primeworks.pt/

3. convert your SQL CE database to a SQL Mobile database and connect to it from Visual Studio 2005 or SQL Server 2005 Management Studio (then select out your records into another SQL Server DB).

-Darren Shaffer|||

Darren,
Can you tell me how to move an .sdf file from sql ce to sql server. I want sdf table data to append with SQL Server's existing data. Is it posible?

Thnx

Raj

|||

With SQL CE, you can't do anything with the .SDF file on your server. You need to get the data out of SQL CE while it is still on a device or emulator and transport the data (not the .SDF file) to your SQL Server. I listed the options for this - it would be very quick to simply write a program that selects out the data from SQL CE and saves it in CSV files. You can then copy the CSV files from your device to your server and then import the data into SQL Server directly from the CSV files. A third party tool like RemoteSQLCE will also handle this for you.

-Darren

|||

Darren,

Thanks a lot for your suggestions, I was looking for tools to analyse sdf databases on a Windows XP environment for a long time!

- Jeroen Boiten

|||

Hallo, I'm Gabriel and I'm working with .NET 2005 and Pocket PC 2003.

I'm very very interested of first point, the one with the CSV export.Do you have an exemple ?

I'm very time stress.

EXTRACTING DATA FROM FOXPRO/ACCESS 2000 INT SQL SERVER 2005

Dear Sir/Madam,

I have some data which is stores in Foxpro dbf files & Access 200 MDB file. Can i extract import these files into SQL Server 2005

Yes.|||

Hi Wilfi,

You can use the FoxPro and Visual FoxPro OLE DB data provider to access the FoxPro DBFs. It is downloadable from http://msdn2.microsoft.com/en-us/vfoxpro/bb190232.aspx .

|||

Dear Cindy,

What i wanted is that, the data which is stored in Access 2000 mdb file to be exported into SQL SERVER 2005.

thanks & with regards,

wilfi