Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 validate objects against sql server keywords

Author  Topic 

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-10-01 : 10:19:47
I just inherited bunch of tables which uses reserved keyworkds in the filed. For example, User, Current, Date, etc.

Is there a way to check this for reserved keywords in tables in a better way? I list of keywords can be obtain from microsoft.

Please suggest. Thanks in advance.

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-10-01 : 10:43:33
select * from information_schema.columns
where column_name in(select keyword from keywords)

Looks like this helped..... Thanks to Me and Google.
Go to Top of Page

mivey4
Yak Posting Veteran

66 Posts

Posted - 2009-10-01 : 10:47:26
Hi Doran_doran!

The following link will provide you with a fairly comprehensive list of T-SQL reserved Keywords.

http://doc.ddart.net/mssql/sql70/ra-rz_8.htm

You can use this list to identify the keywords you want to identify and then use the INFORMATION_SCHEMA of the database where the tables reside to identify them.

If the list of keywords you want to identify are too large to type into the query then I'd suggest one alternative would be to copy and paste the keywords into something like excel and import them into a single field table.

Then you could do something like this:

SELECT TABLE_NAME, COLUMN_NAME
FROM [YourDatabaseName].INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN (SELECT keyname
FROM [YourTableOfKeywords])

Have fun!
Go to Top of Page
   

- Advertisement -