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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | leon1958Starting Member
 
 
                                        4 Posts | 
                                            
                                            |  Posted - 2013-07-01 : 07:18:30 
 |  
                                            | HiHelp please!!I am getting the following error when trying to create this procedure.Msg 207, Level 16, State 1, Procedure getparent, Line 12Invalid column name '.%'.I am pasting the procedure belowCREATE PROCEDURE getparent @newclass varchar(50) asdeclare @parentid int  declare @parentclass varchar(50)/* Gets the parent subject for the subject with the class passed as parameter */	SELECT 	@parentclass=MAX(class) 	FROM subject	WHERE @newclass LIKE RTRIM(ltrim(class))+".%"	select subjectid	from subject 	where class = @parentclassGOThank youSunPower |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 07:19:57 
 |  
                                          | [code]CREATE PROCEDURE getparent @newclass varchar(50) asdeclare @parentid int declare @parentclass varchar(50)/* Gets the parent subject for the subject with the class passed as parameter */SELECT @parentclass=MAX(class) FROM subjectWHERE @newclass LIKE RTRIM(ltrim(class))+ ''.%''select subjectidfrom subject where class = @parentclassGO[/code]it should be two ' rather than a "------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |  
                                          |  |  |  
                                    | lionofdezertAged Yak Warrior
 
 
                                    885 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 07:40:03 
 |  
                                          | CREATE PROCEDURE getparent @newclass varchar(50) asdeclare @parentid int declare @parentclass varchar(50)/* Gets the parent subject for the subject with the class passed as parameter */SELECT @parentclass=MAX(class) FROM subjectWHERE @newclass LIKE RTRIM(ltrim(class))+ '.%'select subjectidfrom subject where class = @parentclassGO--------------------------http://connectsql.blogspot.com/ |  
                                          |  |  |  
                                    | lionofdezertAged Yak Warrior
 
 
                                    885 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 07:43:34 
 |  
                                          | SET QUOTED_IDENTIFIER OFFGOCREATE PROCEDURE getparent @newclass varchar(50) asdeclare @parentid int declare @parentclass varchar(50)/* Gets the parent subject for the subject with the class passed as parameter */SELECT @parentclass=MAX(class) FROM subjectWHERE @newclass LIKE RTRIM(ltrim(class))+".%"select subjectidfrom subject where class = @parentclassGO--------------------------http://connectsql.blogspot.com/ |  
                                          |  |  |  
                                    | leon1958Starting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2013-07-03 : 12:46:46 
 |  
                                          | Thank you very much Lion of the Desert.The command you gave me SET QUOTED_IDENTIFIER OFFWORKS.Thank you again. quote:SunPowerOriginally posted by lionofdezert
 SET QUOTED_IDENTIFIER OFFGOCREATE PROCEDURE getparent @newclass varchar(50) asdeclare @parentid int declare @parentclass varchar(50)/* Gets the parent subject for the subject with the class passed as parameter */SELECT @parentclass=MAX(class) FROM subjectWHERE @newclass LIKE RTRIM(ltrim(class))+".%"select subjectidfrom subject where class = @parentclassGO--------------------------http://connectsql.blogspot.com/
 
 |  
                                          |  |  |  
                                |  |  |  |