tag:blogger.com,1999:blog-5492774.post2121880024571970486..comments2023-12-08T05:54:26.137-05:00Comments on Andrew MacNeill - AKSEL Solutions: SQL: Does a Field Exist?Andrew MacNeillhttp://www.blogger.com/profile/03888444225785506598noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5492774.post-81857736819675813712009-05-03T13:33:00.000-04:002009-05-03T13:33:00.000-04:00Brian,
That would work in VFP - but not in raw SQ...Brian,<br /><br />That would work in VFP - but not in raw SQL.<br /><br />AndrewAndrew MacNeillhttps://www.blogger.com/profile/03888444225785506598noreply@blogger.comtag:blogger.com,1999:blog-5492774.post-5178195176771764842009-05-03T09:57:00.000-04:002009-05-03T09:57:00.000-04:00How about using something like this?
SELECT * FRO...How about using something like this?<br /><br />SELECT * FROM table_name WHERE .f. INTO CURSOR junk<br /><br />IF TYPE("junk.field_name") = "U"<br /> * -- alter table here<br />ENDIF<br />USE IN SELECT("junk")Unknownhttps://www.blogger.com/profile/02360889147524947362noreply@blogger.comtag:blogger.com,1999:blog-5492774.post-12144719859550531752009-04-15T14:45:00.000-04:002009-04-15T14:45:00.000-04:00I agree about SQLCOLUMNS but that is specific to a...I agree about SQLCOLUMNS but that is specific to a SQL Server connection. My quest began when I was trying to find a column name just as easily as I do in VFP. In VFP, I could call SQLCOLUMNS without a problem - and I know there are a few stored procs in SQL that can do it - but I have found this approach works best.Andrew MacNeillhttps://www.blogger.com/profile/03888444225785506598noreply@blogger.comtag:blogger.com,1999:blog-5492774.post-67399916418209387722009-04-15T13:16:00.000-04:002009-04-15T13:16:00.000-04:00Very good stuff. I use the INFORMATION_SCHEMA view...Very good stuff. I use the INFORMATION_SCHEMA views quite a bit for validation in my business objects. One of the nice parts is they are available to just about all users without security restrictions (except for firing the ALTER TABLE command). Another VFP native function I use for similar tasks is SQLCOLUMNS in which if you pass "NATIVE" as the 3rd parameter, you get the table structure information returned. SQLTABLES is another function to validate table existence.Walt Krzystekhttps://www.blogger.com/profile/12169786751653718957noreply@blogger.com