January 30, 2012 at 6:45 am
hi ..does anyone have a script that shows up reserved words used in column/table names .. or some wise words on how to do one ,,, or even a list of reserved words in table format so i could query against information schema columns ?
many thanks
simon
January 30, 2012 at 6:55 am
SQLserver keywords can be found here:
http://msdn.microsoft.com/en-us/library/ms189822.aspx
you can see there is three sets there; SQl keywords, ODBC keywords, and future keywords.
it would be very easy to paste them into a text editor, clean up the whitespace, and stick them in a table.
once it's in the table, it'd simply be something like this:
select
object_name(object_id) As TableName,
colz.name as ColumnName
from sys.columns colz
where colz.name IN (select keyword from ImportedTable)
Lowell
January 30, 2012 at 8:14 am
here you go:
a txt file with all the keywords as a CTE;
at 600+ lines, i did not want to post it inline to teh forum, so tit's a text file instead.
change the select at the bottom to join on sys.columns, and you are all set.
ALL SQL Server Keywords As a CTE in a TXT
Lowell
January 30, 2012 at 9:28 am
I always get a bit nervous when I see people asking for the list of keywords that they intend on using as a lookup to prevent sql injection.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 30, 2012 at 9:47 am
actually it was purely from a poor schema design viewpoint i.e column names which have reserved words and then if you need to call them in a delimited string etc
one of my pet hates but there you go
January 30, 2012 at 9:47 am
thank you kind sir
January 30, 2012 at 9:50 am
Simon_L (1/30/2012)
actually it was purely from a poor schema design viewpoint i.e column names which have reserved words and then if you need to call them in a delimited string etcone of my pet hates but there you go
LOL. We all have our little pet hates and often go to great lengths to rid ourselves of their annoying existence. 😛
I kind of assumed yours was not being used in such a way as to make me shudder since you mentioned querying the schema definitions. I figured you were looking for object names that needed to be changed.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply