Results 1 to 9 of 9

Thread: Get MSSQL field flags with PHP

  1. #1
    Join Date
    May 2003
    Posts
    6

    Get MSSQL field flags with PHP

    Hello,

    I'm currently developing a new database abstraction script. But there are some problems with MSSQL and field flags. How is it possible to get all the information about a field flag (like in MYSQL, e.g. "not_null primary_key auto_increment...")?

    And my second question: Is it possible to list all the user defined databases?

    Thank you for your answers!

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can look at the text of system stored procedure sp_help to see how MS get these info.

    For your table, run this in query analyzer

    sp_help yourtable

    To get a list of user databases query sysdatabases all databases except master, model, msdb and tempdb are user databases.

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    sysdatabases table is located in master database

    select * from master.dbo.sysdatabases where dbid>4

    or

    select * from master.dbo.sysdatabases where name not in ('master','msdb','tempdb','model')

  4. #4
    Join Date
    May 2003
    Posts
    6
    Ok, thank you for yuor help. So my 2nd question is cleared. But with "sp_help tablename" (1st question) I don't get any details about primary keys, index etc.

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    It does display it in SQL2K, I don't have a SQL 70 to verify it. Did you scroll the result window down?.

    If it does not then there is no primary key defined.

  6. #6
    Join Date
    May 2003
    Posts
    6
    I've tested with MSSQL 2003 Beta. But there is no forum for it, thats why I posted here.

  7. #7
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    SQL server 7 and SQL Server 2000 displays all the PK and IDx info.

    May be your table doesnt have any PK or FKs.

    You have yukon Beta?

  8. #8
    Join Date
    May 2003
    Posts
    6
    Don't know what you mean with yukon beta. I have the official beta version from Microsoft (developer program) because I need that version for my content management system "Contentpapst" which has a database abstraction layer.

  9. #9
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    Oh I see.

    I have a obsessive compulsive behaviour of finding YUKON. For me any Beta release looks like YUKON.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •