select LEFT(NAME, LEN(NAME) -9)
from sysobjects where name like '%_CALLLIST' and name not like 'PK_%'
Main Topics
Browse All TopicsNeed help with a simple query referencing sysobjects table. I just migrated our system over to SQL 2005 from SQL 7.0 (big jump) and this one query is giving me problems:
select LEFT(NAME, LEN(NAME) -9)
from sysobjects where name like "%_CALLLIST" and name not like "PK_%"
This basically selects all the tables in that database that have a suffix of "_CallList" at the end of them.
My table names look like this:
OB_OPHTRQ_051107_9715_Call
OB_SBTRQ_050807_CallList
OB_AMMNN_041607_CallList
OB_AMMRQ_041607_RV7001_Cal
OB_AMNN_050907_CallList
The result of this query SHOULD return this:
OB_OPHTRQ_051107_9715
OB_SBTRQ_050807
OB_AMMNN_041607
OB_AMMRQ_041607_RV7001
OB_AMNN_050907
The error that SQL 2005 is telling me:
Msg 207, Level 16, State 1, Line 2
Invalid column name '%_CALLLIST'.
Msg 207, Level 16, State 1, Line 2
Invalid column name 'PK_%'.
I can view all records in sysobjects and I can see that those table names are in the correct format, but simply running a query such as:
select * from sysobjects where name = "OB_AMNN_050907_CallList"
returns me the same kind of error. I just signed up for this service a few days ago, and thought you guys could help. Thanks so much for any guidance!!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: hongjunPosted on 2007-05-25 at 11:32:48ID: 19159025
try this
select LEFT(NAME, LEN(NAME) -9)
from sysobjects where name like '%_CALLLIST' and name not like 'PK_%'