Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Search for columns in tables that are a specific data type?

 
   Database Help (Home) -> MS Access -> Conversion RSS
Next:  Manually storing Data to a field  
Author Message
James R.

External


Since: Oct 28, 2008
Posts: 2



(Msg. 1) Posted: Tue Oct 28, 2008 12:41 pm
Post subject: Search for columns in tables that are a specific data type?
Archived from groups: microsoft>public>access>conversion (more info?)

Hi,

First off I want to start by saying this is an Access 97 question; I know
it's not MS supported and appreciate any help that can be given for this. I'm
working on converting this archaic database to SQL Server 2005; it's quite
the project.

Here is my current problem. I used SSMA for Access some time ago to setup
the initial data structure. Now one thing that didn't get migrated properly
was the AutoNumber data type; it did get migrated as an Integer, but it
didn't get marked as IDENTITY or a seed value placed in for it. So, I'll have
to make this change manually.

The problem is that my database conversion has approximately 180+ tables,
and some of those tables have 30+ fields.

I want to know if there is a Query I can run on the Access 97 database to
list all of the fields (and the table the field is in) that are of the
AutoNumber data type? I know how to do this in SQL but can't seem to find any
correlating system tables that contain this information.

I don't want to have any changes made to the data type or anything...I just
want a simple listing of the fields/tables that have the data type of
AutoNumber so I can simply go into the SQL version and make the proper field
Identity Specific.

If it's of any help the below is a query I've used in SQL to find a BIT data
type for all the tables in the database; this is the same results (or idea)
that I want to accomplish on the Access 97 database. Hopefully this can be
done!

DECLARE @OldDT nvarchar(3)
SET @OldDT = 'bit'
SELECT
o.Name AS Table_Name,
c.Name AS Column_Name
FROM
sys.Objects o JOIN sys.Columns c ON c.Object_id = o.Object_ID
WHERE
o.Type IN ('U')
AND type_name(c.system_type_id) = @OldDT
GROUP BY o.name, c.name;

I appreciate any help that can be provided!

Thanks,
James
--
Knowledge is the first step towards success. Little knowledge creates big
ideas.

 >> Stay informed about: Search for columns in tables that are a specific data type? 
Back to top
Login to vote
Douglas J. Steele

External


Since: Oct 14, 2008
Posts: 236



(Msg. 2) Posted: Tue Oct 28, 2008 5:38 pm
Post subject: Re: Search for columns in tables that are a specific data type? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

No query will give you that information, but you can run some VBA to get it.

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim fldCurr As DAO.Field

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
For Each fldCurr In tdfCurr.Fields
If (fldCurr.Attributes And dbAutoIncrField) <> 0 Then
Debug.Print "Field " & fldCurr.Name & " in table " & _
tdfCurr.Name & " is an AutoNumber field."
End If
Next fldCurr
Next tdfCurr
Set dbCurr = Nothing

That'll write the results to the Immediate window (Ctrl-G)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"James R." <James_DBA RemoveThis @newsgroup.nospam> wrote in message
news:9C67326D-21D9-45F9-8537-EE1609D59EB8@microsoft.com...
> Hi,
>
> First off I want to start by saying this is an Access 97 question; I know
> it's not MS supported and appreciate any help that can be given for this.
> I'm
> working on converting this archaic database to SQL Server 2005; it's quite
> the project.
>
> Here is my current problem. I used SSMA for Access some time ago to setup
> the initial data structure. Now one thing that didn't get migrated
> properly
> was the AutoNumber data type; it did get migrated as an Integer, but it
> didn't get marked as IDENTITY or a seed value placed in for it. So, I'll
> have
> to make this change manually.
>
> The problem is that my database conversion has approximately 180+ tables,
> and some of those tables have 30+ fields.
>
> I want to know if there is a Query I can run on the Access 97 database to
> list all of the fields (and the table the field is in) that are of the
> AutoNumber data type? I know how to do this in SQL but can't seem to find
> any
> correlating system tables that contain this information.
>
> I don't want to have any changes made to the data type or anything...I
> just
> want a simple listing of the fields/tables that have the data type of
> AutoNumber so I can simply go into the SQL version and make the proper
> field
> Identity Specific.
>
> If it's of any help the below is a query I've used in SQL to find a BIT
> data
> type for all the tables in the database; this is the same results (or
> idea)
> that I want to accomplish on the Access 97 database. Hopefully this can be
> done!
>
> DECLARE @OldDT nvarchar(3)
> SET @OldDT = 'bit'
> SELECT
> o.Name AS Table_Name,
> c.Name AS Column_Name
> FROM
> sys.Objects o JOIN sys.Columns c ON c.Object_id = o.Object_ID
> WHERE
> o.Type IN ('U')
> AND type_name(c.system_type_id) = @OldDT
> GROUP BY o.name, c.name;
>
> I appreciate any help that can be provided!
>
> Thanks,
> James
> --
> Knowledge is the first step towards success. Little knowledge creates big
> ideas.

 >> Stay informed about: Search for columns in tables that are a specific data type? 
Back to top
Login to vote
James R.

External


Since: Oct 28, 2008
Posts: 2



(Msg. 3) Posted: Tue Oct 28, 2008 5:38 pm
Post subject: Re: Search for columns in tables that are a specific data type? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Doug,

Thank you; I will try this out. I've also been suggested to use the
Documenter to display the Field Types and Descriptions; which I then would
just do a Find to get the information.

Your idea may present a better format with less work; I like that! =)

Thanks,
James
--
Knowledge is the first step towards success. Little knowledge creates big
ideas.


"Douglas J. Steele" wrote:

> No query will give you that information, but you can run some VBA to get it.
>
> Dim dbCurr As DAO.Database
> Dim tdfCurr As DAO.TableDef
> Dim fldCurr As DAO.Field
>
> Set dbCurr = CurrentDb()
> For Each tdfCurr In dbCurr.TableDefs
> For Each fldCurr In tdfCurr.Fields
> If (fldCurr.Attributes And dbAutoIncrField) <> 0 Then
> Debug.Print "Field " & fldCurr.Name & " in table " & _
> tdfCurr.Name & " is an AutoNumber field."
> End If
> Next fldCurr
> Next tdfCurr
> Set dbCurr = Nothing
>
> That'll write the results to the Immediate window (Ctrl-G)
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "James R." <James_DBA DeleteThis @newsgroup.nospam> wrote in message
> news:9C67326D-21D9-45F9-8537-EE1609D59EB8@microsoft.com...
> > Hi,
> >
> > First off I want to start by saying this is an Access 97 question; I know
> > it's not MS supported and appreciate any help that can be given for this.
> > I'm
> > working on converting this archaic database to SQL Server 2005; it's quite
> > the project.
> >
> > Here is my current problem. I used SSMA for Access some time ago to setup
> > the initial data structure. Now one thing that didn't get migrated
> > properly
> > was the AutoNumber data type; it did get migrated as an Integer, but it
> > didn't get marked as IDENTITY or a seed value placed in for it. So, I'll
> > have
> > to make this change manually.
> >
> > The problem is that my database conversion has approximately 180+ tables,
> > and some of those tables have 30+ fields.
> >
> > I want to know if there is a Query I can run on the Access 97 database to
> > list all of the fields (and the table the field is in) that are of the
> > AutoNumber data type? I know how to do this in SQL but can't seem to find
> > any
> > correlating system tables that contain this information.
> >
> > I don't want to have any changes made to the data type or anything...I
> > just
> > want a simple listing of the fields/tables that have the data type of
> > AutoNumber so I can simply go into the SQL version and make the proper
> > field
> > Identity Specific.
> >
> > If it's of any help the below is a query I've used in SQL to find a BIT
> > data
> > type for all the tables in the database; this is the same results (or
> > idea)
> > that I want to accomplish on the Access 97 database. Hopefully this can be
> > done!
> >
> > DECLARE @OldDT nvarchar(3)
> > SET @OldDT = 'bit'
> > SELECT
> > o.Name AS Table_Name,
> > c.Name AS Column_Name
> > FROM
> > sys.Objects o JOIN sys.Columns c ON c.Object_id = o.Object_ID
> > WHERE
> > o.Type IN ('U')
> > AND type_name(c.system_type_id) = @OldDT
> > GROUP BY o.name, c.name;
> >
> > I appreciate any help that can be provided!
> >
> > Thanks,
> > James
> > --
> > Knowledge is the first step towards success. Little knowledge creates big
> > ideas.
>
>
>
 >> Stay informed about: Search for columns in tables that are a specific data type? 
Back to top
Login to vote
zhen

External


Since: Nov 12, 2008
Posts: 1



(Msg. 4) Posted: Wed Nov 12, 2008 2:25 am
Post subject: Re: Search for columns in tables that are a specific data type? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"James R." <James_DBA.DeleteThis@newsgroup.nospam> 写入消息新闻
:9C67326D-21D9-45F9-8537-EE1609D59EB8@microsoft.com...
> Hi,
>
> First off I want to start by saying this is an Access 97 question; I know
> it's not MS supported and appreciate any help that can be given for this.
I'm
> working on converting this archaic database to SQL Server 2005; it's quite
> the project.
>
> Here is my current problem. I used SSMA for Access some time ago to setup
> the initial data structure. Now one thing that didn't get migrated
properly
> was the AutoNumber data type; it did get migrated as an Integer, but it
> didn't get marked as IDENTITY or a seed value placed in for it. So, I'll
have
> to make this change manually.
>
> The problem is that my database conversion has approximately 180+ tables,
> and some of those tables have 30+ fields.
>
> I want to know if there is a Query I can run on the Access 97 database to
> list all of the fields (and the table the field is in) that are of the
> AutoNumber data type? I know how to do this in SQL but can't seem to find
any
> correlating system tables that contain this information.
>
> I don't want to have any changes made to the data type or anything...I
just
> want a simple listing of the fields/tables that have the data type of
> AutoNumber so I can simply go into the SQL version and make the proper
field
> Identity Specific.
>
> If it's of any help the below is a query I've used in SQL to find a BIT
data
> type for all the tables in the database; this is the same results (or
idea)
> that I want to accomplish on the Access 97 database. Hopefully this can be
> done!
>
> DECLARE @OldDT nvarchar(3)
> SET @OldDT = 'bit'
> SELECT
> o.Name AS Table_Name,
> c.Name AS Column_Name
> FROM
> sys.Objects o JOIN sys.Columns c ON c.Object_id = o.Object_ID
> WHERE
> o.Type IN ('U')
> AND type_name(c.system_type_id) = @OldDT
> GROUP BY o.name, c.name;
>
> I appreciate any help that can be provided!
>
> Thanks,
> James
> --
> Knowledge is the first step towards success. Little knowledge creates big
> ideas.
 >> Stay informed about: Search for columns in tables that are a specific data type? 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> MS Access -> Conversion All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]