September 29, 2010 at 11:00 am
I've inherited an old and massive stored proc. Inside the sp, several ##temp tables are created using "year" as a column name. Tables that are used to load these temp tables also have "year" for column names. The sp seems to be choking on that. I've gone through and changed all references to [year] and get the same error msgs. I can't modify the real tables. Error message is:
"Server: Msg 1038, Level 15, State 3, Line 11
Cannot use empty object or column names. Use a single space if necessary."
if I'm counting my lines correctly, it looks like it's happening on the year = 0 part of inserts like this:
INSERT INTO ##2nd_Append_Public
SELECT
Sign_Year=0,
Sign_Month=0,
Facility_City =VM_FA_Location_City,
Facility_Name =VM_FA_Facility_Name,
RERFT_Certification_No=VM_FA_Certification_No,
Make ="",
Model ="",
Year =0,
Facility_Address =VM_FA_Location_Address,
Facility_Phone =VM_FA_Phone,
Specialize_All_Vehicles =0,
Specialize_Domestic =0,
Specialize_Imports =0,
Specialize_European_Imports =0,
Specialize_Japanese_Imports =0,
.
.
.
any ideas?
September 29, 2010 at 11:38 am
Enclose the keyword in brackets: [Year]
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
September 29, 2010 at 11:58 am
that was my first thought.... didn't work, same errors
September 29, 2010 at 12:28 pm
never mind. That wasn't the offending line, it was the two prior:
Make ="",
Model ="",
didn't like empty string. Used 'null' instead and it works.
Thanks
September 29, 2010 at 12:56 pm
Side note: it may not have balked at the empty string (unless those fields aren't character types), so much as the use of double quotes ("") instead of single ('').
September 29, 2010 at 1:29 pm
ahhhh, thanks for that. I just tested single quotes and that also works. I'd already changed the sp (all 3157 lines of the beast) to use nulls.
...so... I'm sure this sp has been ported up beginning in SQL 6.5, through 7, then 2000. I'm guessing it worked at some point. Where in the chain would that have broken? I see several more of these in my future :o(
September 29, 2010 at 1:46 pm
it can also be a change in set quoted_identifier... quite likely across ?5-10? years of sql server upgrades...
September 29, 2010 at 1:48 pm
It may not like the "" because someone set QUOTED_IDENTIFIER ON. It's looking for an object name between the double quotes.
September 29, 2010 at 1:59 pm
thanks again. The quoted identifiers setting sounds very likely to be the culprit.
Obviously, I'm a fairly new reluctant DBA that's just transfered from applications.
'preciate all help.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply