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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp_executesql and multipart identifier

Author  Topic 

dalibor
Starting Member

21 Posts

Posted - 2008-09-24 : 04:31:36
Hi,

I am trying to create SQL command for sp_executesql
It look like:


SELECT a1,a2,a3,a4,a5
FROM MVCR_OSM.dbo.Presniz as p
LEFT JOIN MV_DB.dbo.c_stupen_vzdelani as c
on p.Stupen_vzdelani = c.text WHERE
c.ID >= 1
c.ID <= 12
and (p.Sluz is null or p.Sluz in ('komisar'))


After the insertion into the procedure executesql
I am obtaining the following error message:


The multi-part identifier "c.ID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "c.ID" could not be bound.
Msg 4104, Level 16, State 1, Line 1


When I run the SELECT statement separately, it goes smooth. No errors.
So it is pretty confusing to me.

Another point to note is that when I run the sp_executesql procedure without the variable "c.ID" , it runs OK as well.

Please a lot for any advice.
Thanx so much in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 04:37:56
do you have ID column in MV_DB.dbo.c_stupen_vzdelani?
Go to Top of Page

dalibor
Starting Member

21 Posts

Posted - 2008-09-24 : 04:42:08
I have "ID", not "id"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 04:53:56
quote:
Originally posted by dalibor

I have "ID", not "id"


that shouldnt be a problem as long as you've case insensitive collation.
Go to Top of Page
   

- Advertisement -