Skip to content
Advertisement

the name is not a valid identifier. error in dynamic stored procudure

my stored procudure is :

when execute show this error: The name ‘SELECT IDproduct,name_product,first_price,final_price,max_registered_price, date_record_shamsi,final_date_view_shamsi, count_views,image_1,collection_1 from Table_asbabbazi where active=0 AND (name_product LIKE %@name_product%) AND (collection_1 = @collection_1 )’ is not a valid identifier. please help

Advertisement

Answer

Some parameters in a query string are not parsed correctly, and you are using dynamic sql it must be executed by EXECUTE sp_executesql statement. This is the correct way to execute dynamic sql:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement