Question : How to detect database type

Hello Experts,

I was curious if there is a standard way (using SQL, or similar approach) to detect which database type is being used.  I have included some sample code below which uses multiple try/catch blocks (in Coldfusion) to test MSSQL, MySQL, Access, Oracle, and DB2.

My ultimate question is : Is there a better way to do this?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:

  
  
    SELECT name
    FROM sysobjects
    WHERE name='#table_name#'
  
  
  
    
      
      
        SELECT name
        FROM sys.objects 
        WHERE name='#table_name#'
      
      
      
        
          
          
            SELECT name
            FROM MSYSObjects
            WHERE Type = 1
            AND name='#table_name#'
          
          
          
            
              
              
                SELECT table_name
                FROM user_tables
                WHERE table_name='#table_name#'
              
              
              
                
                  
                  
                    show tables like '#table_name#'
                  
                  
                  
                    
                      
                      
                        SELECT tabname
                        FROM syscat.columns
                        WHERE tabname='#table_name#'
                      
                      
                      
                        
                      
                    
                  
                
              
            
          
        
      
    
  

Answer : How to detect database type

Random Solutions  
 
programming4us programming4us