Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Thursday, March 29, 2012

Determine table constraints for database upgrade/migration project

I have a project to update one of our program's database from one version to
another. Additionally, I will be migrating the data from one database to
another.
Here's an example:
mydb7.1
mydb8.0
Both databases exist in the same database server.
So mydb7.1 contains production data for an Online store. I need to migrate
this data in to the mydb8.0 database. The mydb8.0 database uses a newer
schema, so there will some work to convert the data to the newer layout.
Here's my problem mydb7.1 database contains hundeds of tables and foreign
key relationships. Is there some way or tool, that can help me determine
the table migration order? That way my code know's which tables to migrat
e
first, and still preserving the ref integrity.
Will it be easier to create the mydb8.0 database, just with tables, and then
migrate the data. After the data is migrated, then setup the foreign key
relations. That way, I will not need order the tables for migration? Jus
t
a thought.
ThanksRichard,
Just a thought...script out the table definitions...alter them...run and
create the tables in the new DB...transfer the data over...views or
dts...script out the PK and FK constraints then apply to the new tables in
the new DB.
HTH
Jerry
"Richard" <Richard@.discussions.microsoft.com> wrote in message
news:69ACA9B4-CB56-417B-8015-B3A168F82F36@.microsoft.com...
>I have a project to update one of our program's database from one version
>to
> another. Additionally, I will be migrating the data from one database to
> another.
> Here's an example:
> mydb7.1
> mydb8.0
> Both databases exist in the same database server.
> So mydb7.1 contains production data for an Online store. I need to
> migrate
> this data in to the mydb8.0 database. The mydb8.0 database uses a newer
> schema, so there will some work to convert the data to the newer layout.
> Here's my problem mydb7.1 database contains hundeds of tables and foreign
> key relationships. Is there some way or tool, that can help me determine
> the table migration order? That way my code know's which tables to
> migrate
> first, and still preserving the ref integrity.
> Will it be easier to create the mydb8.0 database, just with tables, and
> then
> migrate the data. After the data is migrated, then setup the foreign
> key
> relations. That way, I will not need order the tables for migration?
> Just
> a thought.
> Thanks

Thursday, March 22, 2012

detecting Identity in INFORMATION_SCHEMA

I'm developing a SQL Utility program intended to work with multiple brands
of database. Right now we just want to get it working with SQL Server. I
am using INFORMATION_SCHEMA to get information on tables, columns, keys,
etc.
But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
primary key is an Identity column.
Where can I look?
Thanks,
T
Tina,
Try using function columnproperty.
Example:
use northwind
go
select TABLE_NAME, COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where columnproperty(object_id(quotename(TABLE_SCHEMA) + '.' +
quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
go
AMB
"Tina" wrote:

> I'm developing a SQL Utility program intended to work with multiple brands
> of database. Right now we just want to get it working with SQL Server. I
> am using INFORMATION_SCHEMA to get information on tables, columns, keys,
> etc.
> But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
> primary key is an Identity column.
> Where can I look?
> Thanks,
> T
>
>
|||AMB,
Thanks. That worked great!
T
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:6194C838-2DE4-44E0-A895-C99E57E0597A@.microsoft.com...[vbcol=seagreen]
> Tina,
> Try using function columnproperty.
> Example:
> use northwind
> go
> select TABLE_NAME, COLUMN_NAME
> from INFORMATION_SCHEMA.COLUMNS
> where columnproperty(object_id(quotename(TABLE_SCHEMA) + '.' +
> quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
> go
>
> AMB
> "Tina" wrote:
sql

detecting Identity in INFORMATION_SCHEMA

I'm developing a SQL Utility program intended to work with multiple brands
of database. Right now we just want to get it working with SQL Server. I
am using INFORMATION_SCHEMA to get information on tables, columns, keys,
etc.
But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
primary key is an Identity column.
Where can I look?
Thanks,
TTina,
Try using function columnproperty.
Example:
use northwind
go
select TABLE_NAME, COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where columnproperty(object_id(quotename(TABLE_SCHEMA) + '.' +
quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
go
AMB
"Tina" wrote:
> I'm developing a SQL Utility program intended to work with multiple brands
> of database. Right now we just want to get it working with SQL Server. I
> am using INFORMATION_SCHEMA to get information on tables, columns, keys,
> etc.
> But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
> primary key is an Identity column.
> Where can I look?
> Thanks,
> T
>
>|||AMB,
Thanks. That worked great!
T
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:6194C838-2DE4-44E0-A895-C99E57E0597A@.microsoft.com...
> Tina,
> Try using function columnproperty.
> Example:
> use northwind
> go
> select TABLE_NAME, COLUMN_NAME
> from INFORMATION_SCHEMA.COLUMNS
> where columnproperty(object_id(quotename(TABLE_SCHEMA) + '.' +
> quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
> go
>
> AMB
> "Tina" wrote:
>> I'm developing a SQL Utility program intended to work with multiple
>> brands
>> of database. Right now we just want to get it working with SQL Server.
>> I
>> am using INFORMATION_SCHEMA to get information on tables, columns, keys,
>> etc.
>> But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
>> primary key is an Identity column.
>> Where can I look?
>> Thanks,
>> T
>>

detecting Identity in INFORMATION_SCHEMA

I'm developing a SQL Utility program intended to work with multiple brands
of database. Right now we just want to get it working with SQL Server. I
am using INFORMATION_SCHEMA to get information on tables, columns, keys,
etc.
But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
primary key is an Identity column.
Where can I look?
Thanks,
TTina,
Try using function columnproperty.
Example:
use northwind
go
select TABLE_NAME, COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where columnproperty(object_id(quotename(TABLE
_SCHEMA) + '.' +
quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
go
AMB
"Tina" wrote:

> I'm developing a SQL Utility program intended to work with multiple brands
> of database. Right now we just want to get it working with SQL Server. I
> am using INFORMATION_SCHEMA to get information on tables, columns, keys,
> etc.
> But... I can't seem to find where the INFORMATION_SCHEMA tells me if a
> primary key is an Identity column.
> Where can I look?
> Thanks,
> T
>
>|||AMB,
Thanks. That worked great!
T
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:6194C838-2DE4-44E0-A895-C99E57E0597A@.microsoft.com...[vbcol=seagreen]
> Tina,
> Try using function columnproperty.
> Example:
> use northwind
> go
> select TABLE_NAME, COLUMN_NAME
> from INFORMATION_SCHEMA.COLUMNS
> where columnproperty(object_id(quotename(TABLE
_SCHEMA) + '.' +
> quotename(TABLE_NAME)), COLUMN_NAME, 'IsIdentity') = 1
> go
>
> AMB
> "Tina" wrote:
>

Wednesday, March 21, 2012

Detect installed MSDE version

I'm building a setup program that needs to install an instance of SQL Server
if it's not already installed or if it's not up to date. What I need to know
is... how do I know if an instance of SQL Server is installed, and get it's
build version? I can get info about the default instance in the registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MS
SQLServer\MSSQLServer\CurrentVersion
But what about a named instance? If I install an instance called "ABC",
where are settings stored in the registry?
Thanks in advance,
EtienneHi
You may want to cycle around instances in the subkeys of
HKLM\Software\Microsoft\Microsoft SQL Server\
John
"Etienne" <mysteryx93_nosspam@.hotmail.com> wrote in message
news:u$S7IX7jFHA.3144@.TK2MSFTNGP12.phx.gbl...
> I'm building a setup program that needs to install an instance of SQL
> Server if it's not already installed or if it's not up to date. What I
> need to know is... how do I know if an instance of SQL Server is
> installed, and get it's build version? I can get info about the default
> instance in the registry at
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MS
SQLServer\MSSQLServer\CurrentVersi
on
> But what about a named instance? If I install an instance called "ABC",
> where are settings stored in the registry?
> Thanks in advance,
> Etienne
>

Detect installed MSDE version

I'm building a setup program that needs to install an instance of SQL Server
if it's not already installed or if it's not up to date. What I need to know
is... how do I know if an instance of SQL Server is installed, and get it's
build version? I can get info about the default instance in the registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\ MSSQLServer\CurrentVersion
But what about a named instance? If I install an instance called "ABC",
where are settings stored in the registry?
Thanks in advance,
Etienne
Hi
You may want to cycle around instances in the subkeys of
HKLM\Software\Microsoft\Microsoft SQL Server\
John
"Etienne" <mysteryx93_nosspam@.hotmail.com> wrote in message
news:u$S7IX7jFHA.3144@.TK2MSFTNGP12.phx.gbl...
> I'm building a setup program that needs to install an instance of SQL
> Server if it's not already installed or if it's not up to date. What I
> need to know is... how do I know if an instance of SQL Server is
> installed, and get it's build version? I can get info about the default
> instance in the registry at
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\ MSSQLServer\CurrentVersion
> But what about a named instance? If I install an instance called "ABC",
> where are settings stored in the registry?
> Thanks in advance,
> Etienne
>

Sunday, February 19, 2012

design question

Howdy all. I have developers wanting to design a table that will hold not
only client info, but what type of program they are eligible for. I have
narrowed it down to 2 options, but was really looking for opinions. The
current design is like this:
Client Table:
ClientId
LName
FName
(Lots of other info that I will look at later)
IsCash(bit)
IsFoodStamps(bit)
IsMedical(bit)
But I'd like to split it out a bit so the various programs will be in
another table(s):
Option 1:
CLIENT TABLE:
ClientId
LName
FName
PROGRAMS TABLE:
ProgramId
ProgramName
CLIENT PROGRAM LOOKUP TABLE:
ClientId
ProgramId
Option 2:
CLIENT TABLE:
ClientId
LName
FName
CLIENT PROGRAM TABLE:
ClientId
Program (with a CHECK constraint so that only certain values can be entered)
Other ideas are welcomed as well.
TIA, ChrisR> Howdy all. I have developers wanting to design a table that will hold not
> only client info, but what type of program they are eligible for. I have
> narrowed it down to 2 options, but was really looking for opinions. The
> current design is like this:
> Client Table:
> ClientId
> LName
> FName
> (Lots of other info that I will look at later)
> IsCash(bit)
> IsFoodStamps(bit)
> IsMedical(bit)
I'm leaning toward your option 1, or this, with 1 Program = many Clients:
Program table:
ProgramID
Description
Client Table:
ClientID
LName
FName
ProgramID
I think your decision should be based on whether or not a client can belong
to one program at a time, or more than one at a time. So if I can belong to
both Cash and FoodStamps programs, this design won't work and you will want
to go with your Option 1.
--
Peace & happy computing,
Mike Labosh, MCSD MCT
Owner, vbSensei.Com
"Escriba coda ergo sum." -- vbSensei|||To answer your question "yes, a client can and will belong to more than one
program". But why wouldn't Option 2 work?
CLIENT TABLE:
ClientId
LName
FName
CLIENT PROGRAM TABLE:
ClientId
Program
Insert into Client(1234,'Blow','Joe')
Insert into ClientProgram(1234, 'FoodStamps')
Insert into ClientProgram(1234, 'Medical')
I know it's probably not the proper way to do things, but would reduce the
amount of joins. Plus if I had a CHECK constraint on the column "program",
only the right info could be entered.
Thoughts?
"Mike Labosh" <mlabosh_at_hotmail.com> wrote in message
news:OrAyv0gSGHA.4608@.tk2msftngp13.phx.gbl...
not
> I'm leaning toward your option 1, or this, with 1 Program = many Clients:
> Program table:
> ProgramID
> Description
> Client Table:
> ClientID
> LName
> FName
> ProgramID
> I think your decision should be based on whether or not a client can
belong
> to one program at a time, or more than one at a time. So if I can belong
to
> both Cash and FoodStamps programs, this design won't work and you will
want
> to go with your Option 1.
> --
>
> Peace & happy computing,
> Mike Labosh, MCSD MCT
> Owner, vbSensei.Com
> "Escriba coda ergo sum." -- vbSensei
>|||ChrisR wrote:
> To answer your question "yes, a client can and will belong to more than on
e
> program". But why wouldn't Option 2 work?
> CLIENT TABLE:
> ClientId
> LName
> FName
> CLIENT PROGRAM TABLE:
> ClientId
> Program
>
> Insert into Client(1234,'Blow','Joe')
> Insert into ClientProgram(1234, 'FoodStamps')
> Insert into ClientProgram(1234, 'Medical')
> I know it's probably not the proper way to do things, but would reduce the
> amount of joins. Plus if I had a CHECK constraint on the column "program",
> only the right info could be entered.
> Thoughts?
>
Two things to consider. Under option 2 the users won't be able to add
new Programs - that would require a schema change to alter the CHECK
constraint. Also, if you want to change the program description for any
reason then you'll have to change it on every row, not just once.
Perhaps option 2 will also require more storage - it appears so from
your sample data.
In general I'd say that Option 1 is better for "descriptive" text
(because business users are more likely to want changes to
descriptions), whereas Option 2 is better for sets of codes because
they tend to change less frequently.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||"ChrisR" <ChrisR@.noEmail.com> wrote in message
news:eMm9AAhSGHA.4740@.TK2MSFTNGP14.phx.gbl...
> To answer your question "yes, a client can and will belong to more than
> one
> program". But why wouldn't Option 2 work?
It would work.
Option one (clients, programs, and a third table to match the two) is the
standard method for representing a many to many relationship.
Option two would work if the only information about the program that you
care about is the program name. If you plan on entering any other details
about the program, then this isn't good enough.|||I hadn't thought of either of the points you guys vrought up. Thanks a lot
and have a great wend.
"ChrisR" <ChrisR@.noEmail.com> wrote in message
news:eMm9AAhSGHA.4740@.TK2MSFTNGP14.phx.gbl...
> To answer your question "yes, a client can and will belong to more than
one
> program". But why wouldn't Option 2 work?
> CLIENT TABLE:
> ClientId
> LName
> FName
> CLIENT PROGRAM TABLE:
> ClientId
> Program
>
> Insert into Client(1234,'Blow','Joe')
> Insert into ClientProgram(1234, 'FoodStamps')
> Insert into ClientProgram(1234, 'Medical')
> I know it's probably not the proper way to do things, but would reduce the
> amount of joins. Plus if I had a CHECK constraint on the column "program",
> only the right info could be entered.
> Thoughts?
>
> "Mike Labosh" <mlabosh_at_hotmail.com> wrote in message
> news:OrAyv0gSGHA.4608@.tk2msftngp13.phx.gbl...
> not
have
The
Clients:
> belong
belong
> to
> want
>

Design Question

Here is my scenario:
I'm creating a thin client viewer/editor for a client that has a rebate
program.
There are several types of rebate programs, and incentives are different for
each. There are approximately 160 predicating companies and each "reports"
it's sales amount or other qualifying criteria each quarter.
Now, all this is pretty vanilla until, except that the rebate percentage for
each company can change in midstream of a fiscal year.
The old records (pre percentage) change must be kept for viewing only, but
post change must be editable and updateable.
What is the best way to accomplish this without having to nest a lot of
tables?
Thanks in advance for you input..
~ChrisI'd track the old and new percentage rates in a table and based on your
query date (Run from date) you select the proper percentage rate from
that table to use for the calculation.
Ex.
PercentageValidDate Percentage
1/1/2000 6.5
1/1/2003 6.85
6/1/2003 6.93
SELECT TOP 11 Percentage where PercentageValidDATE < [paramater run date]
order by PercentageValidDATE DESC
Smitty wrote:
> Here is my scenario:
> I'm creating a thin client viewer/editor for a client that has a rebate
> program.
> There are several types of rebate programs, and incentives are different for
> each. There are approximately 160 predicating companies and each "reports"
> it's sales amount or other qualifying criteria each quarter.
> Now, all this is pretty vanilla until, except that the rebate percentage for
> each company can change in midstream of a fiscal year.
> The old records (pre percentage) change must be kept for viewing only, but
> post change must be editable and updateable.
> What is the best way to accomplish this without having to nest a lot of
> tables?
> Thanks in advance for you input..
> ~Chris
>

Friday, February 17, 2012

Design Q

I'm going to create a hardware/software inventory program to keep track on all the computers at the office. This program should be able to search the database using queries like "all computers with a cpu faster than 500Mhz".

I want some tips on my database design.

One solution is to create columns for each piece of hardware, i.e. cpu, ram, hdd etc etc. Then just run simple SELECT queries against them. The problem is that a computer may have many HDDs/CDs etc, and also other type of equipment may be entered in the database like switches and routers.

Another solution is to specify the valuetype + value in one table having a relation to another table containing the actual machines/routers/switches. The problem here is that I can't do numeric comparisons this way since "11" is less than "2", ("all computers with a cpu faster than 500Mhz").

Any suggestions?Table Computer
(ComputerID
...)

Table HardwareType
(TypeID
Description)

Table ComputerHardware
(ComputerID
TypeID
Description
NumericValue NULL)

Only use the NumericValue for items where it's relevant, like CPU speed or HDD size and not for things like Keyboards.|||How would I write my SQL statement to get the SQL Server to treat the values as Numeric then?|||They should be stored as numeric values. That's the column 'NumericValue'...

Make it a decimal 18,4 or something similar

design Index problem

Hi all,
I have a very large table with many columns: dateTime type, nvarchar
type and integer field type.
A program exec many type of query with where clause.
Data field is always in where clause, but some other field is present
too. Sometimes integer field, sometimes nvarchar field.
Now I must create index for the query!
For choose index field what i can do?
I must create only index on a datetime field or every combination in
every type of query?
In the second case I must create very much index! But this is very
dispendious for update/insert/delete operation on the table!!!
Some ideas?
thnxEnorme Vigenti (LSimon5@.libero.it) writes:

Quote:

Originally Posted by

I have a very large table with many columns: dateTime type, nvarchar
type and integer field type.
A program exec many type of query with where clause.
Data field is always in where clause, but some other field is present
too. Sometimes integer field, sometimes nvarchar field.
Now I must create index for the query!
For choose index field what i can do?
I must create only index on a datetime field or every combination in
every type of query?
In the second case I must create very much index! But this is very
dispendious for update/insert/delete operation on the table!!!


How selective is the datetime column? If all queries are for a single
day, maybe an index on that column is sufficient, preferrably a clustered
index.

But if queries can be for longer periods of time, that may address too many
rows, and in such case you will need to add more indexes. How these indexes
should be designed depends on the queries. If a query can be on account
number and a date interval, it's probably better to have the account number
first in that index.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||If you could post an example Query ?

--

Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
"Enorme Vigenti" <LSimon5@.libero.itwrote in message
news:0kZSi.151009$U01.1108206@.twister1.libero.it.. .

Quote:

Originally Posted by

Hi all,
I have a very large table with many columns: dateTime type, nvarchar type
and integer field type.
A program exec many type of query with where clause.
Data field is always in where clause, but some other field is present too.
Sometimes integer field, sometimes nvarchar field.
Now I must create index for the query!
For choose index field what i can do?
I must create only index on a datetime field or every combination in every
type of query?
In the second case I must create very much index! But this is very
dispendious for update/insert/delete operation on the table!!!
Some ideas?
thnx