Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restricted word in SQL Server job script

Status
Not open for further replies.

andreis

Programmer
Apr 19, 2001
169
US
Hi, everyone:
I need to drop&re-create an index containing a restricted word (DATE) in a scheduled job. The script works from the Query Analyzer, but doesn't from a job command window. Is there some sort of setting that can resolve this problem?
Thanks
Andrei
 

Try enclosing the column name in brackets - [DATE]. SQL Server provides the ability to use reserved words if they are delimited. Read more under "Reserved Keywords" in SQL BOL.
 
Thank you, tlbroadbent!
It's great to hear from somebody.
The column name is in brackets - [DATE], but no luck.
Andrei
 

Try one of these options.

1- Create a stored proc containing the DROP and CREATE statements. Execute the proc from the job.
2- Use DBCC DBREINDEX to rebuild the index. The basic syntax is
DBCC DBREINDEX ('dbname.owner.tblname', indexname)

Either of these options should work.
 
Thank you, tlbroadbent!

To generate a stored procedure was a great idea that solved our problem. It was a great pleasure to get such a quick and efficient advice!

Andrei
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top