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
 General SQL Server Forums
 New to SQL Server Programming
 sql error

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-04 : 07:45:13
Priya writes "i am getting this error while running my sql script.

Invalid object name 'dbo.'+@TName+''."

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-04 : 07:49:16
Read http://www.sommarskog.se/dynamic_sql.html


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-04 : 09:07:30
quote:
Originally posted by AskSQLTeam

Priya writes "i am getting this error while running my sql script.

Invalid object name 'dbo.'+@TName+''."


Without posting the query you used, it is hard to answer

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-04 : 09:59:50
Not really, it's a dynamic SQL question....again

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-04 : 10:09:14
You need to look at the bigger picture. Like this :


'dbo.'+@TName+''."



It's is clear that there is an extra single quote after the @TName. And why it is end with a double quote ?

'dbo.'+@TName+'.'



KH

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-04 : 10:42:24
Even after escaping single quote with two quotes, it doesn't make sense. Why, use of quote at all? why not something like this:

'dbo.' + @tname + '.'


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-10-04 : 10:43:47
Why are you passing a table name as a variable anyways? ... lets see...

NORMALIZE
FORMAT IN FRONT END
LEARN SQL

did that cover the possibilities?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-04 : 10:54:36
quote:
Originally posted by DonAtWork

Why are you passing a table name as a variable anyways? ... lets see...

NORMALIZE
FORMAT IN FRONT END
LEARN SQL

did that cover the possibilities?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Yes. They will

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-04 : 11:22:13
quote:
Originally posted by DonAtWork

Why are you passing a table name as a variable anyways? ... lets see...

NORMALIZE
FORMAT IN FRONT END
LEARN SQL

did that cover the possibilities?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp



Add one more
- WHY DYNAMIC SQL ?


KH

Go to Top of Page
   

- Advertisement -