Showing posts with label time. Show all posts
Showing posts with label time. Show all posts

Tuesday, March 27, 2012

Database Growth

I would like to know followings:

I want to see every day or weekly Database growth (%) save on table

I have some SP which will give me one time run and see the growth. which is ...

Please advice any other way to find out and save on a location ...

create procedure sp_growth as

set ansi_warnings off

declare @.l_db_name varchar(50)
,@.l_sql_string varchar(1000)

set nocount on
if object_id('DB_Growth') is not null
drop table DB_Growth

create table DB_Growth (Database_Name varchar(30), Logical_File_Name varchar(15), File_Size_MB int, Growth_Factor varchar(100))

declare db_name_cursor insensitive cursor
for
select name from master..sysdatabases

open db_name_cursor

fetch next from db_name_cursor into
@.l_db_name

While (@.@.fetch_status = 0)
begin
select @.l_sql_string = 'select ' + '''' + @.l_db_name + '''' + ', name, ceiling((size * 8192.0)/(1024.0 * 1024.0)), case when status & 0x100000 = 0 then convert(varchar,ceiling((growth * 8192.0)/(1024.0*1024.0))) + '' MB''' + char(10)+char(13)
+ 'else convert (varchar, growth) + '' Percent''' + char(10)+char(13)
+ 'end' + char(10)+char(13)
+ 'from [' + @.l_db_name + '].dbo.sysfiles'
insert into DB_Growth (Database_Name, Logical_File_Name, File_Size_MB, Growth_Factor)
exec (@.l_sql_string)

fetch next from db_name_cursor into
@.l_db_name
end
close db_name_cursor
deallocate db_name_cursor
select * from DB_Growth with (nolock)
if object_id('DB_Growth') is not null
drop table DB_Growth
set nocount off
set ansi_warnings on
return


GO


Thanks
Faiz Farazi
Daudkandi,Comilla, Bangladesh
http://www.databasetimes.net/

Check for responses to your duplicate post in the Transact-SQL forum.

Often, the quality of the responses received is related to our ability to ‘bounce’ ideas off of each other. In the future, to make it easier for us to offer you assistance, and to prevent folks from wasting time on already answered questions, please don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup –and you indicate that you've already posted elsewhere).

Database Growth

I would like to know followings:

I want to see every day or weekly Database growth (%) save on table

I have some SP which will give me one time run and see the growth. which is ...

Please advice any other way to find out and save on a location ...

create procedure sp_growth as

set ansi_warnings off

declare @.l_db_name varchar(50)
,@.l_sql_string varchar(1000)

set nocount on
if object_id('DB_Growth') is not null
drop table DB_Growth

create table DB_Growth (Database_Name varchar(30), Logical_File_Name varchar(15), File_Size_MB int, Growth_Factor varchar(100))

declare db_name_cursor insensitive cursor
for
select name from master..sysdatabases

open db_name_cursor

fetch next from db_name_cursor into
@.l_db_name

While (@.@.fetch_status = 0)
begin
select @.l_sql_string = 'select ' + '''' + @.l_db_name + '''' + ', name, ceiling((size * 8192.0)/(1024.0 * 1024.0)), case when status & 0x100000 = 0 then convert(varchar,ceiling((growth * 8192.0)/(1024.0*1024.0))) + '' MB''' + char(10)+char(13)
+ 'else convert (varchar, growth) + '' Percent''' + char(10)+char(13)
+ 'end' + char(10)+char(13)
+ 'from [' + @.l_db_name + '].dbo.sysfiles'
insert into DB_Growth (Database_Name, Logical_File_Name, File_Size_MB, Growth_Factor)
exec (@.l_sql_string)

fetch next from db_name_cursor into
@.l_db_name
end
close db_name_cursor
deallocate db_name_cursor
select * from DB_Growth with (nolock)
if object_id('DB_Growth') is not null
drop table DB_Growth
set nocount off
set ansi_warnings on
return


GO


Thanks
Faiz Farazi
Daudkandi,Comilla, Bangladesh
http://www.databasetimes.net/

Check for responses to your duplicate post in the Transact-SQL forum.

Often, the quality of the responses received is related to our ability to ‘bounce’ ideas off of each other. In the future, to make it easier for us to offer you assistance, and to prevent folks from wasting time on already answered questions, please don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup –and you indicate that you've already posted elsewhere).

|||

I have never receive solution.

Thanks

Database Growth

I would like to know followings:

I want to see every day or weekly Database growth (%) save on table

I have some SP which will give me one time run and see the growth. which is ...

Please advice any other way to find out and save on a location ...

create procedure sp_growth as

set ansi_warnings off

declare @.l_db_name varchar(50)
,@.l_sql_string varchar(1000)

set nocount on
if object_id('DB_Growth') is not null
drop table DB_Growth

create table DB_Growth (Database_Name varchar(30), Logical_File_Name varchar(15), File_Size_MB int, Growth_Factor varchar(100))

declare db_name_cursor insensitive cursor
for
select name from master..sysdatabases

open db_name_cursor

fetch next from db_name_cursor into
@.l_db_name

While (@.@.fetch_status = 0)
begin
select @.l_sql_string = 'select ' + '''' + @.l_db_name + '''' + ', name, ceiling((size * 8192.0)/(1024.0 * 1024.0)), case when status & 0x100000 = 0 then convert(varchar,ceiling((growth * 8192.0)/(1024.0*1024.0))) + '' MB''' + char(10)+char(13)
+ 'else convert (varchar, growth) + '' Percent''' + char(10)+char(13)
+ 'end' + char(10)+char(13)
+ 'from [' + @.l_db_name + '].dbo.sysfiles'
insert into DB_Growth (Database_Name, Logical_File_Name, File_Size_MB, Growth_Factor)
exec (@.l_sql_string)

fetch next from db_name_cursor into
@.l_db_name
end
close db_name_cursor
deallocate db_name_cursor
select * from DB_Growth with (nolock)
if object_id('DB_Growth') is not null
drop table DB_Growth
set nocount off
set ansi_warnings on
return


GO


Thanks
Faiz Farazi
Daudkandi,Comilla, Bangladesh
http://www.databasetimes.net/

Check for responses to your duplicate post in the Transact-SQL forum.

Often, the quality of the responses received is related to our ability to ‘bounce’ ideas off of each other. In the future, to make it easier for us to offer you assistance, and to prevent folks from wasting time on already answered questions, please don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup –and you indicate that you've already posted elsewhere).

|||

I have never receive solution.

Thanks

Database Growth

I would like to know followings:

I want to see every day or weekly Database growth (%) save on table

I have some SP which will give me one time run and see the growth. which is ...

Please advice any other way to find out and save on a location ...

create procedure sp_growth as

set ansi_warnings off

declare @.l_db_name varchar(50)
,@.l_sql_string varchar(1000)

set nocount on
if object_id('DB_Growth') is not null
drop table DB_Growth

create table DB_Growth (Database_Name varchar(30), Logical_File_Name varchar(15), File_Size_MB int, Growth_Factor varchar(100))

declare db_name_cursor insensitive cursor
for
select name from master..sysdatabases

open db_name_cursor

fetch next from db_name_cursor into
@.l_db_name

While (@.@.fetch_status = 0)
begin
select @.l_sql_string = 'select ' + '''' + @.l_db_name + '''' + ', name, ceiling((size * 8192.0)/(1024.0 * 1024.0)), case when status & 0x100000 = 0 then convert(varchar,ceiling((growth * 8192.0)/(1024.0*1024.0))) + '' MB''' + char(10)+char(13)
+ 'else convert (varchar, growth) + '' Percent''' + char(10)+char(13)
+ 'end' + char(10)+char(13)
+ 'from [' + @.l_db_name + '].dbo.sysfiles'
insert into DB_Growth (Database_Name, Logical_File_Name, File_Size_MB, Growth_Factor)
exec (@.l_sql_string)

fetch next from db_name_cursor into
@.l_db_name
end
close db_name_cursor
deallocate db_name_cursor
select * from DB_Growth with (nolock)
if object_id('DB_Growth') is not null
drop table DB_Growth
set nocount off
set ansi_warnings on
return


GO


Thanks
Faiz Farazi
Daudkandi,Comilla, Bangladesh
http://www.databasetimes.net/

Hi Faiz,

You could use the following. Used in SQL 2000 and I use it for SQL 2005.

Code Snippet

use database_name

go

dbcc showfilestats

go

For log file sizes:

Code Snippet

dbcc SQLperf(logspace)

go

more over sysfiles, only shows the file size allocated, not being used.

regards

Jag

Database Grow Problems

I am having problems when I try to grow my database. It seems to be taken a
long time (1 hour and still going) and is also making the system
unresponsive. The CPU is at 0 but the computer is so slow nothing can be
done. This is a dual processor system with 2ghz processors. I am using the
express version and am trying to grow a database from 45 mb to the maximum
of 4096 mb.
Is this normall or is there something wrong with the hard drive, system or
database? I ran the dbcc tool and it did not report any problem with the
tables or index.
The reason I decided to grow it to the max is because my incremental grows
were slowing down my application. I figured if I set it to the maximum it
would speed things up. I didn't know growing it would take this long.
Bob
That seems excessive for just 4GB of growth but by default it will have to
zero initialize every bit in the file. This normally takes a while and
depends heavily on the hardware as to how long. If you are running on
Windows XP or Windows 2003 then you may be able to take advantage of Instant
file initialization. From BOL:
Instant file initialization is only available if the SQL Server
(MSSQLSERVER) service account has been granted SE_MANAGE_VOLUME_NAME.
Members of the Windows Administrator group have this right and can grant it
to other users by adding them to the Perform Volume Maintenance Tasks
security policy. For more information about assigning user rights, see the
Windows documentation.
Andrew J. Kelly SQL MVP
"Bob" <msgdev@.hotmail.com> wrote in message
news:%23RvjnVQVGHA.5288@.TK2MSFTNGP14.phx.gbl...
>I am having problems when I try to grow my database. It seems to be taken
>a long time (1 hour and still going) and is also making the system
>unresponsive. The CPU is at 0 but the computer is so slow nothing can be
>done. This is a dual processor system with 2ghz processors. I am using
>the express version and am trying to grow a database from 45 mb to the
>maximum of 4096 mb.
> Is this normall or is there something wrong with the hard drive, system or
> database? I ran the dbcc tool and it did not report any problem with the
> tables or index.
> The reason I decided to grow it to the max is because my incremental grows
> were slowing down my application. I figured if I set it to the maximum it
> would speed things up. I didn't know growing it would take this long.
>
> Bob
>

Database Grow Problems

I am having problems when I try to grow my database. It seems to be taken a
long time (1 hour and still going) and is also making the system
unresponsive. The CPU is at 0 but the computer is so slow nothing can be
done. This is a dual processor system with 2ghz processors. I am using the
express version and am trying to grow a database from 45 mb to the maximum
of 4096 mb.
Is this normall or is there something wrong with the hard drive, system or
database? I ran the dbcc tool and it did not report any problem with the
tables or index.
The reason I decided to grow it to the max is because my incremental grows
were slowing down my application. I figured if I set it to the maximum it
would speed things up. I didn't know growing it would take this long.
BobThat seems excessive for just 4GB of growth but by default it will have to
zero initialize every bit in the file. This normally takes a while and
depends heavily on the hardware as to how long. If you are running on
Windows XP or Windows 2003 then you may be able to take advantage of Instant
file initialization. From BOL:
Instant file initialization is only available if the SQL Server
(MSSQLSERVER) service account has been granted SE_MANAGE_VOLUME_NAME.
Members of the Windows Administrator group have this right and can grant it
to other users by adding them to the Perform Volume Maintenance Tasks
security policy. For more information about assigning user rights, see the
Windows documentation.
Andrew J. Kelly SQL MVP
"Bob" <msgdev@.hotmail.com> wrote in message
news:%23RvjnVQVGHA.5288@.TK2MSFTNGP14.phx.gbl...
>I am having problems when I try to grow my database. It seems to be taken
>a long time (1 hour and still going) and is also making the system
>unresponsive. The CPU is at 0 but the computer is so slow nothing can be
>done. This is a dual processor system with 2ghz processors. I am using
>the express version and am trying to grow a database from 45 mb to the
>maximum of 4096 mb.
> Is this normall or is there something wrong with the hard drive, system or
> database? I ran the dbcc tool and it did not report any problem with the
> tables or index.
> The reason I decided to grow it to the max is because my incremental grows
> were slowing down my application. I figured if I set it to the maximum it
> would speed things up. I didn't know growing it would take this long.
>
> Bob
>sql

Database Grow Problems

I am having problems when I try to grow my database. It seems to be taken a
long time (1 hour and still going) and is also making the system
unresponsive. The CPU is at 0 but the computer is so slow nothing can be
done. This is a dual processor system with 2ghz processors. I am using the
express version and am trying to grow a database from 45 mb to the maximum
of 4096 mb.
Is this normall or is there something wrong with the hard drive, system or
database? I ran the dbcc tool and it did not report any problem with the
tables or index.
The reason I decided to grow it to the max is because my incremental grows
were slowing down my application. I figured if I set it to the maximum it
would speed things up. I didn't know growing it would take this long.
BobThat seems excessive for just 4GB of growth but by default it will have to
zero initialize every bit in the file. This normally takes a while and
depends heavily on the hardware as to how long. If you are running on
Windows XP or Windows 2003 then you may be able to take advantage of Instant
file initialization. From BOL:
Instant file initialization is only available if the SQL Server
(MSSQLSERVER) service account has been granted SE_MANAGE_VOLUME_NAME.
Members of the Windows Administrator group have this right and can grant it
to other users by adding them to the Perform Volume Maintenance Tasks
security policy. For more information about assigning user rights, see the
Windows documentation.
Andrew J. Kelly SQL MVP
"Bob" <msgdev@.hotmail.com> wrote in message
news:%23RvjnVQVGHA.5288@.TK2MSFTNGP14.phx.gbl...
>I am having problems when I try to grow my database. It seems to be taken
>a long time (1 hour and still going) and is also making the system
>unresponsive. The CPU is at 0 but the computer is so slow nothing can be
>done. This is a dual processor system with 2ghz processors. I am using
>the express version and am trying to grow a database from 45 mb to the
>maximum of 4096 mb.
> Is this normall or is there something wrong with the hard drive, system or
> database? I ran the dbcc tool and it did not report any problem with the
> tables or index.
> The reason I decided to grow it to the max is because my incremental grows
> were slowing down my application. I figured if I set it to the maximum it
> would speed things up. I didn't know growing it would take this long.
>
> Bob
>

Wednesday, March 21, 2012

Database Errors

I'm trying to script a SQL server 7 database using the
tool in EM. Every time I try I get error 220 Arithmetic
overflow error for data type smallint, value = 65535.
It's quite clearly correct in that it is out of range,
what I don't understand is why and what I can do to
resolve this error. After I found this out I discovered
that all the databases on this server give the same error
when I try to look at their properties using enterprise
manager.
Does anyone have any ideas what is causing this and how I
can prevent it
replies please to elwoosAThotmailDOTcom
thanksTry to script the objects seperately and see where this error occurs.
Other way to scritping:
http://www.nigelrivett.net/DMOScripting.html
http://www.nigelrivett.net/DMOScriptAllDatabases.html
"elwoos" wrote:

> I'm trying to script a SQL server 7 database using the
> tool in EM. Every time I try I get error 220 Arithmetic
> overflow error for data type smallint, value = 65535.
> It's quite clearly correct in that it is out of range,
> what I don't understand is why and what I can do to
> resolve this error. After I found this out I discovered
> that all the databases on this server give the same error
> when I try to look at their properties using enterprise
> manager.
> Does anyone have any ideas what is causing this and how I
> can prevent it
> replies please to elwoosAThotmailDOTcom
> thanks
>

Database Errors

I'm trying to script a SQL server 7 database using the
tool in EM. Every time I try I get error 220 Arithmetic
overflow error for data type smallint, value = 65535.
It's quite clearly correct in that it is out of range,
what I don't understand is why and what I can do to
resolve this error. After I found this out I discovered
that all the databases on this server give the same error
when I try to look at their properties using enterprise
manager.
Does anyone have any ideas what is causing this and how I
can prevent it
replies please to elwoosAThotmailDOTcom
thanks
Try to script the objects seperately and see where this error occurs.
Other way to scritping:
http://www.nigelrivett.net/DMOScripting.html
http://www.nigelrivett.net/DMOScriptAllDatabases.html
"elwoos" wrote:

> I'm trying to script a SQL server 7 database using the
> tool in EM. Every time I try I get error 220 Arithmetic
> overflow error for data type smallint, value = 65535.
> It's quite clearly correct in that it is out of range,
> what I don't understand is why and what I can do to
> resolve this error. After I found this out I discovered
> that all the databases on this server give the same error
> when I try to look at their properties using enterprise
> manager.
> Does anyone have any ideas what is causing this and how I
> can prevent it
> replies please to elwoosAThotmailDOTcom
> thanks
>

Monday, March 19, 2012

Database Discussion to change perpective

Hello

I have been doing relational database forever(or a long time) and have been intruduces to a team that uses a highly normalized database(propietary) to manage workflow.

We are capturing data in an AUDIT Trail EAV format.(500 million rows)

It is my task to build this into a data warehouse for reporting and I need to have with my team a relational database discussion. The relational database knowledge on this team is DB2 based, IDMS, and other past evolutions.

The common processes used are recieve a flat file and process this file sequentially using C# or VB doing lookups of other databse tables and writing out another flat file to be converted in XML for load to the propritary system.

My goal is to attempt to introduce new design concepts to my team and these are some talking points that I have come up with for a lunch and learn session.

can anyone else add to this list I don't want to get into a deep discussion about 3rd NF, Star Schemas vs Snowflake, etc.. I want to keep is informational and light to eliceit discussion and relat it back to older technologies.

some of the topics we can discuss are:
Why the data warehouse
Real-time tables what needs to stay in prod
What is going to happen to reporting database
Interaction between database on the same cluster/server
Interaction between databases on different servers (linked servers not allowed)
Set processing as opposed to cursor processing.
Table types
EAV
Type1
Type2
Fact
Dimensions
CodeYou could consider a demonstration of speed by getting together a flatfile of data, and then import it with the old way, then with BCP or BULKINSERT. I find people respond to demos better than theoretical discussion.

Sunday, March 11, 2012

Database differences

We have a database that when an update is released (and this is very often) the release notes don't cover most of the actual changes. Every time groups of our custom queries and reports get broken due to database changes. Does anyone know how to compare two databases and get a report of the differences between them? I can either have the two versions on the same server or on different servers if that makes a difference.

I'm hoping for something where you input @.oldversion, @.newversion

and return is

@.oldversion, tblname, fieldname, char(8)
@.newversion, tblname, fieldname, varchar(8)
@.oldversion, tblname, [Null], [Null]
@.newversion, tblname, fieldname, int
@.oldversion, [Null]
@.newversion, tblname

also any changes in dependancies

Thanks
Brent--sp_addlinkedserver @.server = 'NJROS1D98'
--sp_addlinkedserver @.server = 'NJROS1A144'
--select * from sysservers

--select * from njros1a144.vigncontent.dbo.TBL_EDG_PAGE

--sp_addlinkedserver
-- 'NJEPWA103',
-- 'Oracle',
-- 'MSDAORA',
-- 'ORC1'

--Select * from NJEPWA103.ORC1.dbo.sysobjects

/* Objects in Pru Missing in NetCo */
Select 'Table Objects in Pru but are not in NetCo'
select Left(a.name,30), a.refdate from sysobjects a
Where a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (Select 1 From njros1a144.vigncontent.dbo.sysobjects b where a.name = b.name)

/* Objects in NetCo Missing in Pru */
Select 'Table Objects in NetCo but are not in Pru'
select Left(a.name,30), a.refdate from njros1a144.vigncontent.dbo.sysobjects a
Where a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (Select 1 From sysobjects b where a.name = b.name)

/* Column Differences */

Select 'Column Differences between like named tables'

select Left(x.TabName,30) as TableName, Left(x.ColName,30) as ColumnName
, Left(x.DataType,15) as PruDataType, x.length as PruLength, x.refdate as PruRefDate
, Left(y.DataType,15) as NetCoDataType, y.length As NetCoLength, y.refdate as NetCoRefDate
from
( Select a.name as TabName, b.name as ColName, b.length, c.name as DataType, a.refdate
from sysobjects a, syscolumns b, systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U' and a.name like 'TBL%') As x
, ( Select a.name as TabName, b.name as ColName, b.length, c.name as DataType, a.refdate
from njros1a144.vigncontent.dbo.sysobjects a, njros1a144.vigncontent.dbo.syscolumns b, njros1a144.vigncontent.dbo.systypes c
where a.id = b.id and a.xtype = 'U'
and b.xusertype = c.xusertype
and a.name like 'TBL%') As y
Where x.TabName = y.TabName
and x.ColName = y.ColName
and (x.length <> y.length or x.DataType <> y.DataType)

/* Column Differences */
Select 'Column in Pru.com not in NetCo'

Select Left(a.name,30) as TableName, Left(b.name,30) as ColumnName, b.length, c.name, a.refdate
from sysobjects a, syscolumns b, systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (
Select 1
from njros1a144.vigncontent.dbo.sysobjects d, njros1a144.vigncontent.dbo.syscolumns e
where d.id = e.id
and a.xtype = 'U'
and a.name like 'TBL%'
and a.name = d.name
and b.name = e.name)
Order by 1, 2

/* Column Differences */
Select 'Column in NetCo not in Pru.com'

Select Left(a.name,30) as TableName, Left(b.name,30) as ColumnName, b.length, c.name, a.refdate
from njros1a144.vigncontent.dbo.sysobjects a, njros1a144.vigncontent.dbo.syscolumns b, njros1a144.vigncontent.dbo.systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (
Select 1
from sysobjects d, syscolumns e
where d.id = e.id
and a.xtype = 'U'
and a.name like 'TBL%'
and a.name = d.name
and b.name = e.name)
Order by 1, 2

--Select 'Table Objects that are still in use in both NetCo and Pru'
--select Left(a.name,30), a.refdate from sysobjects a, njros1a144.vigncontent.dbo.sysobjects b where a.name = b.name and a.xtype = 'U'

Gotta change this to use the INFORMATION_SCHEMA views...|||Do you mean replace sysobj with Information_schema?

Not clear on where the modification you mention at the end takes place, can clearly see where I have to replace your server.db names with my own.

Thanks,

Brent|||Do you mean replace sysobj with Information_schema?

Not clear on where the modification you mention at the end takes place, can clearly see where I have to replace your server.db names with my own.

Thanks,

Brent|||No...for now, just replace

njros1a144.vigncontent.dbo

Change the Server.database.owner...that you want to compare one to the other

And run the code on the database that needs to be compared...

just cut and paste the code in to a query analyser window...

good luck...|||I just wanted to change the code so it uses the schemas, because the damn ccatalog is sooooo convaluted...I wrote this awhile back when I didn't know about the views...

You gotta do a sp_helptext against sp_help...

very funny comments in there...|||I was just prepping a response for this:

Changing the names for our names looks to work great, thank you very much. One further question, is there a way to use variable for the dbname/s as follows:

Declare
@.newver
@.oldver

Set @.newver = newverion
set @.oldver = oldserver.oldversion

use @.newver

Below is what I'm running now. For the above example I would like to replace all of the 'oldserver.oldversion' entries to use the @.oldver variable, but when I try it query analyser reads the path as @.oldver instead of the set value. Any ideas?

Again thanks a ton

Brent

Select 'Table Objects in ' + (Select lkpversion.version from lkpversion) + ' but are not in ' +(Select version from oldserver.oldversionname.dbo.lkpversion)
select Left(a.name,30) as TableName, a.refdate from sysobjects a
Where a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (Select 1 From oldserver.oldversionname.dbo.sysobjects b where a.name = b.name)

/* Objects in old Version Missing in New Version */
Select 'Table Objects in ' + (select version from oldserver.oldversionname.dbo.lkpversion) +' but are not in '+ (select lkpversion.version from lkpversion)
select Left(a.name,30) as TableName, a.refdate from oldserver.oldversionname.dbo.sysobjects a
Where a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (Select 1 From sysobjects b where a.name = b.name)

/* Column Differences */

Select 'Column Differences between like named tables'

select Left(x.TabName,30) as TableName, Left(x.ColName,30) as ColumnName
, Left(x.DataType,15) as NewVerType, x.length as NewVerLength, x.refdate as NewVerRefDate
, Left(y.DataType,15) as OldVerType, y.length As OldVerLength, y.refdate as OldVerRefDate
from
( Select a.name as TabName, b.name as ColName, b.length, c.name as DataType, a.refdate
from sysobjects a, syscolumns b, systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U' and a.name like 'TBL%') As x
, ( Select a.name as TabName, b.name as ColName, b.length, c.name as DataType, a.refdate
from oldserver.oldversionname.dbo.sysobjects a, oldserver.oldversionname.dbo.syscolumns b, oldserver.oldversionname.dbo.systypes c
where a.id = b.id and a.xtype = 'U'
and b.xusertype = c.xusertype
and a.name like 'TBL%') As y
Where x.TabName = y.TabName
and x.ColName = y.ColName
and (x.length <> y.length or x.DataType <> y.DataType)

/* Column Differences */
Select 'Column in ' + (Select lkpversion.version from lkpversion) +' not in ' + (Select version from oldserver.oldversionname.dbo.lkpversion)

Select Left(a.name,30) as TableName, Left(b.name,30) as ColumnName, b.length, c.name, a.refdate
from sysobjects a, syscolumns b, systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (
Select 1
from oldserver.oldversionname.dbo.sysobjects d, oldserver.oldversionname.dbo.syscolumns e
where d.id = e.id
and a.xtype = 'U'
and a.name like 'TBL%'
and a.name = d.name
and b.name = e.name)
Order by 1, 2

/* Column Differences */
Select 'Column in '+ (Select version from oldserver.oldversionname.dbo.lkpversion) + ' but are not in ' +(Select lkpversion.version from lkpversion)

Select Left(a.name,30) as TableName, Left(b.name,30) as ColumnName, b.length, c.name, a.refdate
from oldserver.oldversionname.dbo.sysobjects a, oldserver.oldversionname.dbo.syscolumns b, oldserver.oldversionname.dbo.systypes c
where a.id = b.id
and b.xusertype = c.xusertype
and a.xtype = 'U'
and a.name like 'TBL%'
and Not Exists (
Select 1
from sysobjects d, syscolumns e
where d.id = e.id
and a.xtype = 'U'
and a.name like 'TBL%'
and a.name = d.name
and b.name = e.name)
Order by 1, 2|||You'd need to do dynamic SQL with an EXEC(@.sql)

What is lkpversion?

Those have to stay as the system tables I coded...|||Originally posted by Brett Kaiser
You'd need to do dynamic SQL with an EXEC(@.sql)

What is lkpversion?

Those have to stay as the system tables I coded...

lkpversion is a table that contains the version number of the software.

So what I get is a descriptive field lik:

tables in version 3.8 not in version 3.7

Database Diagrams tool

When I use the sql 2005 "Database Diagrams" tool for the first time I always get the message: "The Database does not have one or more of the support objects required to use database diagramming. Do you wish to create them?"

1. Does anyone know what the " support objects" referred to are?

2. Why SQL doesn't automatically create these support objects for me? (e.g. do they require a lot of hard disk space so they shouldn't routinely be created?)

3. Is there any way to make Sql automatically create them?

If you can address any of these points I'd appreciate it.

TIA,

barkingdog


The support objects are the following objects that will be created during the action:

sp_helpdiagramdefinition
sp_creatediagram
sp_renamediagram
sp_alterdiagram
sp_dropdiagram
fn_diagramobjects
sp_upgraddiagrams
sysdiagrams
PK__sysdiagrams__ID
UK_principal_name
sp_helpdiagrams

I don′t know why they are not created at creation time of the database, but you can influence this design by creating the definitions once in the model database. As the model database is the template for new database, once theay are created here, they will exists in every new database.


HTH, Jens SUessmeyer.


http://www.sqlserver2005.de

|||

I create all my databases from a script, and I can't always guarantee the model database design.

Is there a single system sproc that can be called to generate all those bits?

Otherwise - what's the best way to get all those bits into the model database? You can't add a diagram to the model database..

Thanks...

|||


As noone prevents you from scripting the stored procedures and related objects, just script them and put them in your custom script you are executing.

HTH, Jens SUessmeyer.


http://www.sqlserver2005.de

Wednesday, March 7, 2012

Database design question with time

Im designing a database where a user enters the date and the number of
hours and minutes he worked for the day..now i can do this

Workdate small date
Hours integer
Minutes integer

But then would I have to have the front end know that when adding up
the hours and minutes for the week that 60 minutes = 1 hour or is
there some way to do this in the database?

thanks

-JimJim (jim.ferris@.motorola.com) writes:
> Im designing a database where a user enters the date and the number of
> hours and minutes he worked for the day..now i can do this
> Workdate small date
> Hours integer
> Minutes integer
>
> But then would I have to have the front end know that when adding up
> the hours and minutes for the week that 60 minutes = 1 hour or is
> there some way to do this in the database?

You could have a computed column with the forumla Minutes + 60 * Hours:

CREATE TABLE workhours (
userid userid_type NOT NULL,
workdate smalldatetime NOT NULL,
hours tinyint NOT NULL,
minutes tinyint NOT NULL,
worked_minutes AS minutes + 60 * hours,
CONSTRAINT pk_workhours(userid, workdate))

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||>> ... database where a user enters the date and the number of hours
and minutes he worked for the day..<<

Use a duration instead of trying to create your own temporal datatype
system.

CREATE TABLE Timecard
(emp_id INTEGER NOT NULL,
start_time DATETIME NOT NULL,
finish_time DATETIME, -- null means still active
PRIMARY KEY (emp_id, start_time));

You can now use BETWEEN predicates and a calendar table.|||Thanks Ill try that

-Jim

Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns9474F24297CBCYazorman@.127.0.0.1>...
> Jim (jim.ferris@.motorola.com) writes:
> > Im designing a database where a user enters the date and the number of
> > hours and minutes he worked for the day..now i can do this
> > Workdate small date
> > Hours integer
> > Minutes integer
> > But then would I have to have the front end know that when adding up
> > the hours and minutes for the week that 60 minutes = 1 hour or is
> > there some way to do this in the database?
> You could have a computed column with the forumla Minutes + 60 * Hours:
> CREATE TABLE workhours (
> userid userid_type NOT NULL,
> workdate smalldatetime NOT NULL,
> hours tinyint NOT NULL,
> minutes tinyint NOT NULL,
> worked_minutes AS minutes + 60 * hours,
> CONSTRAINT pk_workhours(userid, workdate))

Friday, February 17, 2012

Database data

Hi all! I have a problem... My server went down about a week ago, and they are fixing it, in the time that they are fixing it i want to pass my database table with all the information inside it, to another server, and they gave me the database to get all the information from there...

My problem is... how i can pass all the information inside my database to my another database, the database server is sql 2000, and the other is also sql 2000, i want to generate a script so i can pass it to the other database and fill the database with the data in the script...

I have Microsoft Sql server manager, and i try to play around with it, but can't find out how to generate a script that contains all the data from the database or table.. have also the microsoft sql server database publishing wizard... but can't generate the script also...

so if anyone can give me a clue as of how to generate my script with the information from a table, or the whole database...

thank you!...

Try the DTS Import/Export wizard under Tools -> Data Transformation Services -> Import/Export (Depending on whether you are pulling or pushing data) in the Enterprise Manager.|||I have the sql server managment studio express... where is that DTS?|||

Oh ok. Prbly its not available in the Express edition. How big is the table (how many records)? I fits a few hundred thousand rows you can do a simple INSERT INTO query. Are the 2 databases on the same server or diff servers?

INSERT INTO server1.db1.dbo.Table (<column list>

SELECT <column list>

FROM server2.db2.dbo.table

WHERE <condition>

This will create the table in the Db1 as well as populate data from table on Db2. You might still need to create the indexes/build the FK's etc.

Database Creation Help

Hi All,
I am trying to build a prototype in vb with sql server backend, I have a que
stion regarding the database , due to time constraints i am in a dilema whet
her to build a normalized database or to build a denormalized database and n
ormalize it later'
Which will be a good decision?
Thanks for any help
Sudha.If you don't have time to do it right, where are you going to find the time
to do it over? At least Normalize the biggest pieces.
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"sudha" <anonymous@.discussions.microsoft.com> wrote in message
news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
quote:

> Hi All,
> I am trying to build a prototype in vb with sql server backend, I have a

question regarding the database , due to time constraints i am in a dilema
whether to build a normalized database or to build a denormalized database
and normalize it later'
quote:

> Which will be a good decision?
>
> Thanks for any help
> Sudha.
>
|||I meant total Normalization ofcourse.Apllication comes into picture only aft
er approval for the project .
Thanks.|||Usual industry practice is to throw away the prototype code when you are
building it for production.
If that is what you anticipate, I guess either way is fine.
But if you want to prove your design concept and if that is the reason you
are building a prototype, then I would do it right the first way, which is
normalized way.
Keep in mind in certain hybrid systems of OLTP/OLAP, the data is
denormalized deliberately for optimum performance between OLTP and Reporting
operations.
HTH
Satish Balusa
Corillian Corp.
"sudha" <anonymous@.discussions.microsoft.com> wrote in message
news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
quote:

> Hi All,
> I am trying to build a prototype in vb with sql server backend, I have a

question regarding the database , due to time constraints i am in a dilema
whether to build a normalized database or to build a denormalized database
and normalize it later'
quote:

> Which will be a good decision?
>
> Thanks for any help
> Sudha.
>
|||Thanks for the advice.
sudha
quote:

>--Original Message--
>Usual industry practice is to throw away the prototype

code when you are
quote:

>building it for production.
>If that is what you anticipate, I guess either way is

fine.
quote:

>But if you want to prove your design concept and if that

is the reason you
quote:

>are building a prototype, then I would do it right the

first way, which is
quote:

>normalized way.
>Keep in mind in certain hybrid systems of OLTP/OLAP, the

data is
quote:

>denormalized deliberately for optimum performance between

OLTP and Reporting
quote:

>operations.
>--
>HTH
>Satish Balusa
>Corillian Corp.
>
>"sudha" <anonymous@.discussions.microsoft.com> wrote in

message
quote:

>news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
backend, I have a[QUOTE]
>question regarding the database , due to time constraints

i am in a dilema
quote:

>whether to build a normalized database or to build a

denormalized database
quote:

>and normalize it later'
>
>.
>

Database Creation Help

Hi All,
I am trying to build a prototype in vb with sql server backend, I have a question regarding the database , due to time constraints i am in a dilema whether to build a normalized database or to build a denormalized database and normalize it later'
Which will be a good decision?
Thanks for any help
Sudha.If you don't have time to do it right, where are you going to find the time
to do it over? At least Normalize the biggest pieces.
--
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"sudha" <anonymous@.discussions.microsoft.com> wrote in message
news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
> Hi All,
> I am trying to build a prototype in vb with sql server backend, I have a
question regarding the database , due to time constraints i am in a dilema
whether to build a normalized database or to build a denormalized database
and normalize it later'
> Which will be a good decision?
>
> Thanks for any help
> Sudha.
>|||I meant total Normalization ofcourse.Apllication comes into picture only after approval for the project .
Thanks.|||Usual industry practice is to throw away the prototype code when you are
building it for production.
If that is what you anticipate, I guess either way is fine.
But if you want to prove your design concept and if that is the reason you
are building a prototype, then I would do it right the first way, which is
normalized way.
Keep in mind in certain hybrid systems of OLTP/OLAP, the data is
denormalized deliberately for optimum performance between OLTP and Reporting
operations.
--
HTH
Satish Balusa
Corillian Corp.
"sudha" <anonymous@.discussions.microsoft.com> wrote in message
news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
> Hi All,
> I am trying to build a prototype in vb with sql server backend, I have a
question regarding the database , due to time constraints i am in a dilema
whether to build a normalized database or to build a denormalized database
and normalize it later'
> Which will be a good decision?
>
> Thanks for any help
> Sudha.
>|||Thanks for the advice.
sudha
>--Original Message--
>Usual industry practice is to throw away the prototype
code when you are
>building it for production.
>If that is what you anticipate, I guess either way is
fine.
>But if you want to prove your design concept and if that
is the reason you
>are building a prototype, then I would do it right the
first way, which is
>normalized way.
>Keep in mind in certain hybrid systems of OLTP/OLAP, the
data is
>denormalized deliberately for optimum performance between
OLTP and Reporting
>operations.
>--
>HTH
>Satish Balusa
>Corillian Corp.
>
>"sudha" <anonymous@.discussions.microsoft.com> wrote in
message
>news:47AACA23-7420-4BF2-9B10-5F37F44123C5@.microsoft.com...
>> Hi All,
>> I am trying to build a prototype in vb with sql server
backend, I have a
>question regarding the database , due to time constraints
i am in a dilema
>whether to build a normalized database or to build a
denormalized database
>and normalize it later'
>> Which will be a good decision?
>>
>> Thanks for any help
>> Sudha.
>
>.
>