.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Error for Single quotes in dynamic query

Posted By: Senthilnathan     Posted Date: October 12, 2011    Points:5   Category :Sql Server
Hi All,

I'm creating dynamic query inside the Stored procedure by using some variables. In that some variable having value with single quotes. So the query giving error. How to solve this? Plz help me on this.

Example :

declare @variable as varchar(25)declare @qry as varchar(100)set @variable='testest'+''+'test'select @variableset @qry='select '+@variableselect @qryexec(@qry)

Responses
Author: Narayanan             
Posted Date: October 12, 2011     Points: 20   

HI ,
What is the Error? and please explain your query .
Regards,
Lakshmi Narayanan.S

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Aamrapali Tamgadge             
Posted Date: October 13, 2011     Points: 20   

hi Senthilnathan can u explain what error u r getting.


Software Programmer At OTIS ISRC
Author: sriram             
Posted Date: October 27, 2011     Points: 20   


declare @variable as varchar(25)declare @qry as varchar(100)set @variable='testest'+''+'test'select @variableset @qry='select '+@variableselect @qryexec(@qry)

u must declare the @variableset...


Regards
Sriram.R



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend