Showing posts with label tables. Show all posts
Showing posts with label tables. Show all posts

Friday, March 30, 2012

How to truncate complete database?

Hello,

I want to truncate all tables present in the particular database, Is there any simple way to do it? or do I have to do it on individula basis (table by table)?

regards

When you say truncate, do you just want to remove all records from all tables? The easiest way would be to script out the tables with drop and create statements. To actually truncate the tables, you could write a cursor to loop through the table names and to run dynamic sql to truncate each table.

I hope this helps.

|||

Zadoras wrote:

Hello,

I want to truncate all tables present in the particular database, Is there any simple way to do it? or do I have to do it on individula basis (table by table)?

regards

create a script to drop all your FK constraints

create a script to create all your FK constraints

To do this, right click on the database and "Generate Scripts.."

Then

1 - run your script to drop all Fks

2 - use the sp_MSForEachTable stored procedure to truncate all tables

EXEC sp_MSForEachTable 'Truncate Table ?'

3 - run your script to add all the FKs back|||thanx very much for your support

Wednesday, March 28, 2012

How to Translate an Oracle DataBase to SQL Server DataBase with constraints and

Hello,

Mr. rnealejr:
I use MS SQL Server 2000.
Also, I have a problem with SQL Server.
I have about 50 tables and views in an Oracle DataBase and I have tried to translate them to SQL Server DataBases.
They were translated succefully but there was two problems :
1- Key constraints were not translated? (i.e. the destination SQL Server database became without primary key and foreign key constraints and aother constraints)
2- Also, views are translated into tables not into view ??

Could you slove these problems?

After I get more information I will be able to serve your good forum with good posts becuase until now I am student

Thank you very much

ShihabMaybe you can 'reverse engineer' the Oracle database with a data modelling tool (e.g. ERwin) and then 'forward engineer' that schema to SQL Server.
I don't know whether views also can go through this trajectory, but since the syntax of creating views is the same (although SQL Server 2000 doesn't do the create or replace trick) you can build these views from the statements you can see within the Oracle Enterprise Manager or TOAD. Save the creation statements of both the tables, constraints and views in a script. You'll always need it at least once.

Edwin|||Originally posted by edwin
Maybe you can 'reverse engineer' the Oracle database with a data modelling tool (e.g. ERwin) and then 'forward engineer' that schema to SQL Server.
I don't know whether views also can go through this trajectory, but since the syntax of creating views is the same (although SQL Server 2000 doesn't do the create or replace trick) you can build these views from the statements you can see within the Oracle Enterprise Manager or TOAD. Save the creation statements of both the tables, constraints and views in a script. You'll always need it at least once.

Edwin

I am very sorry, I don't understand what you mean by 'reverse engineer' and 'forward engineer'
Could you clearify these terms ??
Thank you very much|||"reverse engineer" "forward engineer" (http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=%22reverse+engineer%22++%22forward+engineer%22)

rudy
http://rudy.ca/

how to transfer to multiple tables based on environment

How is it possible to set data to flow through development,test,and production environment?

I have created one package.Right now i am transferring data to tables in the development environment.

I want to use the same package for several diffrent distinations two based on environment.

Is there a way that the destination componnent sets itself automatically by passing destination tables through registry or is there anything i could or do i need to change manually everytime which ever i want to..

I think Package configurations will do that for you. You can make your package 'portable' through environments by using them. Search this forum; there is a lot of info on that|||Configurations are designed to help you change the environment without alter the code in your package. You can use them to set connect strings, etc dynamically at runtime. If you right-click in an empty area of your package, the menu will contain an option for package configurations. There's good information in Books Online and this forum on how to use them.|||

Is it possible to change the connection for the lookups which i have used in the package..

|||Yes, by setting the connection string for the connection manager used in the lookup.|||sorry for not been clear ...is it possible to change connection in lookup using package configuration..|||I don't think I am understanding your question. Do you want to change the connection the lookup is using? If so, the answer is yes. If you are asking if you can use the lookup to change another connection string, the answer is no (at least not easily.) Could you describe your scenario in a little more detail?|||

sureshv wrote:

sorry for not been clear ...is it possible to change connection in lookup using package configuration..

The lookup component like the OLE DB components and other source destinations, use connection managers. The connection managers have properties. Then you can use package configurations to change those properties at run time (e.g connection strings) without having to change the package.

So, the short answer is YES.

Look in this forum and BOL for package configurations and you will get a better understanding.

|||will it cause any problem if i set the package configuration after creating the entire package..|||No, you should be able to set up configurations at any time.

how to transfer to multiple tables based on environment

How is it possible to set data to flow through development,test,and production environment?

I have created one package.Right now i am transferring data to tables in the development environment.

I want to use the same package for several diffrent distinations two based on environment.

Is there a way that the destination componnent sets itself automatically by passing destination tables through registry or is there anything i could or do i need to change manually everytime which ever i want to..

I think Package configurations will do that for you. You can make your package 'portable' through environments by using them. Search this forum; there is a lot of info on that|||Configurations are designed to help you change the environment without alter the code in your package. You can use them to set connect strings, etc dynamically at runtime. If you right-click in an empty area of your package, the menu will contain an option for package configurations. There's good information in Books Online and this forum on how to use them.|||

Is it possible to change the connection for the lookups which i have used in the package..

|||Yes, by setting the connection string for the connection manager used in the lookup.|||sorry for not been clear ...is it possible to change connection in lookup using package configuration..|||I don't think I am understanding your question. Do you want to change the connection the lookup is using? If so, the answer is yes. If you are asking if you can use the lookup to change another connection string, the answer is no (at least not easily.) Could you describe your scenario in a little more detail?|||

sureshv wrote:

sorry for not been clear ...is it possible to change connection in lookup using package configuration..

The lookup component like the OLE DB components and other source destinations, use connection managers. The connection managers have properties. Then you can use package configurations to change those properties at run time (e.g connection strings) without having to change the package.

So, the short answer is YES.

Look in this forum and BOL for package configurations and you will get a better understanding.

|||will it cause any problem if i set the package configuration after creating the entire package..|||No, you should be able to set up configurations at any time.

How to transfer data from SQL Server 2000 to Db2 V8 using DTS and Odbc driver

hi all,

I am trying to create a dts package to transfer data from tables in my
sql server 2000 database to a db2 UDB v8.1.4 database. When I use ibm
db2 oledb driver for the destination this works fine except that rows
are committed on a row by row basis thus performance is slow. I want
to use the odbc driver but when I define it as the destination, i get
errors saying that the maximum number of rows failed has exceeded the
minimum.

Does anybody know what to do in order to get the transfer working
using ibm db2 odbc as the datasource?

Thanks
Lyn"Lyn Duong" <lynd@.tablimited.com.au> wrote in message
news:8d1cda6d.0407061859.2b9da589@.posting.google.c om...
> hi all,
> I am trying to create a dts package to transfer data from tables in my
> sql server 2000 database to a db2 UDB v8.1.4 database. When I use ibm
> db2 oledb driver for the destination this works fine except that rows
> are committed on a row by row basis thus performance is slow. I want
> to use the odbc driver but when I define it as the destination, i get
> errors saying that the maximum number of rows failed has exceeded the
> minimum.
> Does anybody know what to do in order to get the transfer working
> using ibm db2 odbc as the datasource?
> Thanks
> Lyn

I guess the error message is actually "The number of failing rows exceeds
the maximum
specified"? That is a very general error, but there should be a more
detailed error message immediately after it in the log, which may give a
clue to the issue - can you post the full error message?

Simon|||Hi,

Yes, I logged the errors in an exception file and in an error file
I suspect that the odbc driver is not parsing the record properly

The exception file contains
DATA TRANSFORMATION SERVICES: Data Pump Exception Log

Package Name: (null)
Package Description: (null)
Package ID: {AE67DD38-6E64-4184-B5EB-6EE519F9CE9A}
Package Version: {AE67DD38-6E64-4184-B5EB-6EE519F9CE9A}
Step Name: DTSStep_DTSDataPumpTask_1
Execution Started: 8/07/2004 9:43:51 AM
Error at Destination for Row number 1. Errors encountered so far in
this task: 1. |1|609||||||||IS

The error file contains
The execution of the following DTS Package succeeded:

Package Name: (null)
Package Description: (null)
Package ID: {AE67DD38-6E64-4184-B5EB-6EE519F9CE9A}
Package Version: {AE67DD38-6E64-4184-B5EB-6EE519F9CE9A}
Package Execution Lineage: {6AE6BF2C-8187-4A9F-AA5F-2565B873DC51}
Executed On: ROULETTE
Executed By: lynd
Execution Started: 8/07/2004 9:43:50 AM
Execution Completed: 8/07/2004 9:43:51 AM
Total Execution Time: 0.25 seconds

Package Steps execution information:

Step 'DTSStep_DTSDataPumpTask_1' failed

Step Error Source: Microsoft Data Transformation Services (DTS) Data
Pump
Step Error Description:The number of failing rows exceeds the maximum
specified. ( (80004005): )
Step Error code: 8004206A
Step Error Help File:sqldts80.hlp
Step Error Help Context ID:0

Step Execution Started: 8/07/2004 9:43:50 AM
Step Execution Completed: 8/07/2004 9:43:51 AM
Total Step Execution Time: 0.22 seconds
Progress count in Step: 0
************************************************** **************************************************

Any ideas ? Thanks!
"Simon Hayes" <sql@.hayes.ch> wrote in message news:<40ec34b4$1_1@.news.bluewin.ch>...
> "Lyn Duong" <lynd@.tablimited.com.au> wrote in message
> news:8d1cda6d.0407061859.2b9da589@.posting.google.c om...
> > hi all,
> > I am trying to create a dts package to transfer data from tables in my
> > sql server 2000 database to a db2 UDB v8.1.4 database. When I use ibm
> > db2 oledb driver for the destination this works fine except that rows
> > are committed on a row by row basis thus performance is slow. I want
> > to use the odbc driver but when I define it as the destination, i get
> > errors saying that the maximum number of rows failed has exceeded the
> > minimum.
> > Does anybody know what to do in order to get the transfer working
> > using ibm db2 odbc as the datasource?
> > Thanks
> > Lyn
> I guess the error message is actually "The number of failing rows exceeds
> the maximum
> specified"? That is a very general error, but there should be a more
> detailed error message immediately after it in the log, which may give a
> clue to the issue - can you post the full error message?
> Simonsql

How to Transfer data from AS400 to SQL 2005

Hi All,

I have to transfer AS400 files to Sql 2005 tables .For this I am using the DTS wizard. I am able to connect to AS400 Database and in the Wizard when I give the sql statement Select * from table1 the statement is parsed. In the next step however I am geting DTS unhandled exception with no error message.

"An error occured which the SQL Server Integration services wizard was not prepared to handle.
No error message available,result codeBig SmileB_E_CANTCANCEL(0*80040E15).(System.Data)".

I am not able to proceed further. Pls let me know what I should do?

I am using IBMDB2 UDBFOR ISEREIS IBMDA400 OLE DB PROVIDER to connect to AS400 from the DTS wizard and IBM Client Access Tool to connect to AS400.

How can I transfer Data from AS400 files to Sql 2005 tables using the DTS wizard?

Regds,

Anu

What is the DTS wizard with respect to SSIS?|||

if you do a search you should find a few topics related to people trying to use the native OLE DB drivers to access AS/400 data. Most of us (me included) seem to have given up trying to solve the problem and are just using the IBM-provided ODBC driver instead.

Of course, this could mean your packages need some alteration since SSIS has some differences depending on the type of connection being used (e.g. Datareader vs. OLEDB sources).

Monday, March 26, 2012

How to track changes to a table using system tables ?

I would like to get a report on a monthly basis as to what tables were
changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
columns on a regular basis. sysobjects has only crdate (object creation date)
but not modify datetime. Is there a way to get that ?
TIA
MO
MO
SQL Server does not track changes like drop/modify
Visit www.dbazine.com. There you will be found a great script written by
Gregory A. Larsen (Monitoring changed objects)
"MO" <MO@.discussions.microsoft.com> wrote in message
news:0603078E-4248-419A-AA8B-C6CF0AD0D3E9@.microsoft.com...
> I would like to get a report on a monthly basis as to what tables were
> changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
> columns on a regular basis. sysobjects has only crdate (object creation
date)
> but not modify datetime. Is there a way to get that ?
> TIA
> MO
sql

How to track changes to a table using system tables ?

I would like to get a report on a monthly basis as to what tables were
changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
columns on a regular basis. sysobjects has only crdate (object creation date)
but not modify datetime. Is there a way to get that ?
TIA
MOMO
SQL Server does not track changes like drop/modify
Visit www.dbazine.com. There you will be found a great script written by
Gregory A. Larsen (Monitoring changed objects)
"MO" <MO@.discussions.microsoft.com> wrote in message
news:0603078E-4248-419A-AA8B-C6CF0AD0D3E9@.microsoft.com...
> I would like to get a report on a monthly basis as to what tables were
> changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
> columns on a regular basis. sysobjects has only crdate (object creation
date)
> but not modify datetime. Is there a way to get that ?
> TIA
> MO

How to track changes to a table using system tables ?

I would like to get a report on a monthly basis as to what tables were
changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
columns on a regular basis. sysobjects has only crdate (object creation date
)
but not modify datetime. Is there a way to get that ?
TIA
MOMO
SQL Server does not track changes like drop/modify
Visit www.dbazine.com. There you will be found a great script written by
Gregory A. Larsen (Monitoring changed objects)
"MO" <MO@.discussions.microsoft.com> wrote in message
news:0603078E-4248-419A-AA8B-C6CF0AD0D3E9@.microsoft.com...
> I would like to get a report on a monthly basis as to what tables were
> changed(from a DDL standpoint) in the last 30 days ? We add/drop/modify
> columns on a regular basis. sysobjects has only crdate (object creation
date)
> but not modify datetime. Is there a way to get that ?
> TIA
> MO

Wednesday, March 21, 2012

How to tell if a table is being used.

Currently I've been assigned the glorious task of cleaning up our database. I've gone ahead and marked a sizable list of tables that I don't believe are accessed anymore. Now, I need to find out whether or not they are being accessed. I've ran sp_depends on all of them to find out what stored procedures/triggers may be accessing them, and the plate is clear. But, there are many individual programs, reports, etc... running against this database, so I'm going to need more proof than that. My boss suggested some sort of SELECT trigger, but that doesn't exist (to what I've found) for SQL Server 2000.

So, does anyone know how to determine if a table is being accessed or not (other than manually looking through thousands of lines of code)?

Thanks for any help you can give me.If you happen to have a test system, go ahead and rename the tables, and do a round of testing. Good luck.|||Originally posted by MCrowley
If you happen to have a test system, go ahead and rename the tables, and do a round of testing. Good luck.
I wish it were that simple. There is no test environment that tests all the applications/reports/etc... that are accessing this database. And, if I rename the tables, I've been told that the stored procedures will continue to work properly, while programs executing miscellaneous queries will fail. My initial idea has been to create copies of all the tables that I want to delete (named tablename_DELETE) and drop the original tables. Then if "shit hits the fan", I can rename the backup copy table back to its original form.

This still puts me in a situation where I have a lot of uncertainty about what I will be affecting. That's why I wanted to find some sort of an access log, or SELECT triger, or something I could use to see if these tables were being accessed.|||You can periodically look into syscacheobjects table and see if helps.|||Originally posted by rdjabarov
You can periodically look into syscacheobjects table and see if helps.
Good idea. I'm formulating some sort of a job to check this now, but I really curious to know what happens on instances where a table is accessed sparingly. In this case, would an entry exist in the syscacheobjects?|||What about using SQL Profiler and running a trace?|||Also you could use Profiler for saving tables activity (only selects, inserts, deletes and updates) and analyzing.|||Originally posted by Brett Kaiser
What about using SQL Profiler and running a trace?
You are reading my mind... ;)|||The profiler idea is a good one. I'm going to try that out.

Thanks for the help!|||My only qualm about Profiler is that it may not be able to pick up views an/or procedures that access this table. I know sysdepends did not show anything, but how accurate is that?|||I sometimes log procedure execution by creating the following table:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ProcedureLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ProcedureLog]
GO
CREATE TABLE [dbo].[ProcedureLog] (
[ProcessName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ProcessTime] [datetime] NULL ,
[Application] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CurrentUser] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SystemUser] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ProcedureLog] WITH NOCHECK ADD
CONSTRAINT [DF_ProcedureLog_ProcessTime] DEFAULT (getdate()) FOR [ProcessTime]
GO
setuser
GO
EXEC sp_bindefault N'[dbo].[DF_SYS_APPNAME]', N'[ProcedureLog].[Application]'
GO
EXEC sp_bindefault N'[dbo].[DF_SYS_USERNAME]', N'[ProcedureLog].[CurrentUser]'
GO
EXEC sp_bindefault N'[dbo].[DF_STRING_EMPTY]', N'[ProcedureLog].[Notes]'
GO
EXEC sp_bindefault N'[dbo].[DF_STRING_EMPTY]', N'[ProcedureLog].[ProcessName]'
GO
EXEC sp_bindefault N'[dbo].[DF_SYS_SUSERSNAME]', N'[ProcedureLog].[SystemUser]'
GO
setuser
GO

...and then putting this code at the start of each procedure I want to monitor:

--Record the event
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ProcedureLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
insert into dbo.ProcedureLog (ProcessName) values ('YourProcedureName')

This monitors who, what, and when a procedure is called.

You could put the same code in a trigger on a table.

Actually, I also include a notes field where I pass the values of all the parameters submitted to the procedure, but this may not be necessary for what you want to do.|||Yeah, except as the poster said, - there are no dependent ptocedures found for the tables that he wants to research the usage of.

You could put the same code in a trigger on a table.

Have they come up with a trigger for SELECT already? Man, the technology is just leaping into the future, leaving us behind every day :)|||Old technology, actually.

Just because a relationship doesn't show up in sysdepends doesn't mean it doesn't exist. Dynamic dependencies are not documented in sysdepends.

And as far as searching for references, maybe you should just script out your database and application code and do string searches for the suspect objects.|||Originally posted by blindman
Old technology, actually.

Just because a relationship doesn't show up in sysdepends doesn't mean it doesn't exist. Dynamic dependencies are not documented in sysdepends.

And as far as searching for references, maybe you should just script out your database and application code and do string searches for the suspect objects.

Nah...he's worried about applcation connecting to the server...

There are no TRIGGERS for SELECT btw

bol

{ [DELETE] [,] [INSERT] [,] [UPDATE] }

Are keywords that specify which data modification statements, when attempted against this table or view, activate the trigger. At least one option must be specified. Any combination of these in any order is allowed in the trigger definition. If more than one option is specified, separate the options with commas.

For INSTEAD OF triggers, the DELETE option is not allowed on tables that have a referential relationship specifying a cascade action ON DELETE. Similarly, the UPDATE option is not allowed on tables that have a referential relationship specifying a cascade action ON UPDATE.|||Thanks, Brett, that's what I thought :)|||Originally posted by Brett Kaiser
Nah...he's worried about applcation connecting to the server...

There are no TRIGGERS for SELECT btw

bol
Yes, I was more worried about external programs running adhoc queries than I was about stored procedures accessing the tables. I felt reasonably confident with the sp_depends, and I even searched the syscomments system table for references to the tables in quetion in the text field. So, basically a SELECT trigger would be an ideal option, but the profiler is serving its purpose for now. I'm going to give it a week, and if I haven't seen any activity by then, I'm smoking the tables.

Thanks again, for all the help

Monday, March 12, 2012

How to synchronize 2 tables on different sql servers

Hi, anybody can help me.

How can i synchronize 2 tables on 2 different sql servers 2000

i mean TABLE1(col1, col2, col3, col4) and
TABLE1(col1, col2, col3, col4, col5, col6)

the first 3 colums are the same in rwo tables.

Thanks

--
Message posted via http://www.sqlmonster.comalex via SQLMonster.com (forum@.nospam.SQLMonster.com) writes:
> Hi, anybody can help me.
> How can i synchronize 2 tables on 2 different sql servers 2000
> i mean TABLE1(col1, col2, col3, col4) and
> TABLE1(col1, col2, col3, col4, col5, col6)
>
> the first 3 colums are the same in rwo tables.

Could you be more specific on what you mean. Do you want to synchronize
data or metadata? And what should the synchronization result in?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for replay, i want to synchronize
data between two tables? i don't know how to acomplish that.
Maybe u can suggest me some stuff to read about topic?

P.S. i had read your articles about Error Handling very helpful.

thanks

--
Message posted via http://www.sqlmonster.com|||alex via SQLMonster.com (forum@.SQLMonster.com) writes:
> Thanks for replay, i want to synchronize
> data between two tables? i don't know how to acomplish that.
> Maybe u can suggest me some stuff to read about topic?

Well, if you know you are in A and want to go B, I might be able to
help you, if you tell me where A and B are.

But if you don't know where you want to go, then I cannot help you with
that part. "Synchronize the tables" could mean a lot of things, and I'm
not active in this newsgroup to play guessing games.

Please give an example of what you have, and where you want to arrive.
Then we might be able to suggest something.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Ok, sorry about my explanation .

I have two sql servers that runs on different machines

each of sql servers have database (there is not same database) however
there is table (suppose myTable) that is same to two databases and i need
to synchronize between them in this case e.g.

sqlServer1 myTable1
sqlServer2 myTable2

in case some data is changed in [sqlServer1 myTable1] i need that
[sqlServer2 myTable2] will changed too according to [sqlServer1 myTable1]
and not vice versa i.e i need that [sqlServer2 myTable2] will ALLWAYS have
data like [sqlServer1 myTable1]

--
Message posted via http://www.sqlmonster.com|||alex via SQLMonster.com (forum@.SQLMonster.com) writes:
> Ok, sorry about my explanation .
> I have two sql servers that runs on different machines
> each of sql servers have database (there is not same database) however
> there is table (suppose myTable) that is same to two databases and i need
> to synchronize between them in this case e.g.
>
> sqlServer1 myTable1
> sqlServer2 myTable2
> in case some data is changed in [sqlServer1 myTable1] i need that
> [sqlServer2 myTable2] will changed too according to [sqlServer1 myTable1]
> and not vice versa i.e i need that [sqlServer2 myTable2] will ALLWAYS have
> data like [sqlServer1 myTable1]

One method is to set up replication, although a replication topology
for one single table is probably an overkill. Also, that would require
the tables to have the same metadata, and your initial post indicated
that they have different columns.

Another method is to set up SqlServer2 as a linked server on
SqlServer1, and then have a trigger that replicates the data to
the table on SqlServer2. If the network is not always up, or if it is
slow, this can cause updates on Server1 to be slow.

Yet another possibility is to set up Server1 as a linked server on Server2,
and regularly poll, for instance from SQL Server Agent. If the table
is moderate in size, it might be feasible to simply truncate the
table, and then load the data over. Of course, this won't do, if the
table is has many rows.

Yet a possibiliy is a combination of the last two: you have a trigger
which writes to a table local to Server1, and then Server2 pulls the
chagens from this table, and then deletes the rows in the table. Here
some care needs to be taken so that you don't miss any updates, but
also you don't lock the source tables for updates while fetching.

Which of these to choose depends on your exact requirements, which
privileges you can run this under, which possibilities you have to
set up linked servers and create triggers etc.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||thanks, this more that i expect.

--
Message posted via http://www.sqlmonster.com

Wednesday, March 7, 2012

How to store/display more than one tables/recordset

see the follow code:
can return more than one recordset/table
the datagrid can show more than one table at a time.
1.the problem is how to store more than one table in a dataset at a time.
2.see sql(2),sql(3), the new table 't1' is empty, after exec sql(3) will meet a "System.Data.OleDb.OleDbException",the sql(2) can pass without return recordset, but sql(3) return a null recordset(maybe). What should I do.
thanks.

Public Function m_execsql()
Dim connStr As String
connStr = "User ID=sa;Password=sa;Initial Catalog=Northwind;Provider=""SQLOLEDB.1"";Data Source=MINGLEI"
conn = New System.Data.OleDb.OleDbConnection(connStr)
conn.Open()
Dim sql(3) As String
sql(0) = "select * from products;"
sql(1) = "select * from orders;"
sql(2) = "create table t1;"
sql(3) = "seletc * from t1;"
Dim i As Integer
For i = 0 To sql.GetUpperBound(0) - 1
Try
da = New OleDb.OleDbDataAdapter(sql(i), conn)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
'Try
ds = New DataSet("dsTable")
dt = New DataTable
da.Fill(ds)
'grd.SetDataBinding(ds, i.ToString)
grd.DataSource = dt
'Catch eds As Exception
' MessageBox.Show(eds.Message)
'End T
Next
conn.Close()
conn = Nothing
End Functioniqueen, you can use multiple data adapters to fill one dataset or if your sql statement returned more than one result set.

Here's more from MS KB:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpopulatingdatasetfromdataadapter.asp

You may want post in .Net section too...

Sunday, February 19, 2012

How to start with historization of dimensions!?

Hi there, I've got a question regarding the historization of dimension tables. How do I approach it at best? Let's say I've got 4 dimensions I want to apply historization to (article, customer, agent, forwarding). What is the starting point in Analysis Services?

Things that aren't clear to me:

1. If I use snapshot for historization I think all of the tables need to have 3 additional columns added (at the moment I've just got data-table without time stamps). Let's take an exemplary look at the article table:

Code Snippet

artno artgroup comgroup brand description

4711 Orange Juice Fresh TropicalWonder


So, If I am correct I need to add these rows in order to guarantee a historization:

Code Snippet

artno valid from valid to last refresh
4711 2005-01-01 2005-12-31 2006-01-01
4711 2006-01-01 2099-12-31 2006-01-01


2. If this is correct, my second problem is, how do generate these informations?

3. And last but not least, how does a cube draw a distinction between the two values? As the fact table is just connected to the dimension via the artno...

Thanks in advance!

Hello! These are my comments:

1. Correct, but you are missing a technical/surrogate key which is an simple integer. You can create one column in the dimension table like:artkey int indentity(1,1) .

2. You do this in the ETL process, that is in SSIS(Integration services)

3. The fact table will connect to the dimension table with the surrogate key, not the source key. You will find the valid surrogate key by using the time stamps in the dimension table and compare them with the time stamp of the fact record in SSIS. In the cube you will have a problem with fragmentation of the information.

On my blog(http://thomasianalytics.spaces.live.com/) I have some comments regarding pros and cons with slowly changing dimension. Look for "Slowly changing dimensions or avoid that problem" . You can read a good comment by Tim Petersson

HTH

Thomas Ivarsson

|||Thanks, great post!!!