<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Fix : Error : Incorrect syntax near . You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel</title>
	<atom:link href="http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:36:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: kirti Patel</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-224380</link>
		<dc:creator><![CDATA[kirti Patel]]></dc:creator>
		<pubDate>Fri, 23 Dec 2011 11:28:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-224380</guid>
		<description><![CDATA[Hi Pinal,
Here is my SQL Script to Create TESTDB. I Try to Create DB on SQL Server 2008 R2 But got Lots error Can you tell me what&#039;s wrong. I am not expert on SQL Server. I can create DB Desing but I am tring to create DB Run-time on my Program. Here are code....

DECLARE @InstanceName varchar(100), 
                @InstanceLocation varchar(100),
                @InstancePath varchar(100)
                
SELECT @InstanceName = convert(varchar, ServerProperty(&#039;InstanceName&#039;))
EXEC master..xp_regread @rootkey=&#039;HKEY_LOCAL_MACHINE&#039;,
  @key=&#039;Software\Microsoft\Microsoft SQL Server\Instance Names\SQL&#039;,
  @value_name=&#039;SQLEXPRESS&#039;,
  @value=@InstanceLocation OUTPUT
SELECT @InstanceLocation = &#039;Software\Microsoft\Microsoft SQL Server\&#039;+@InstanceLocation+&#039;\Setup&#039;

EXEC master..xp_regread @rootkey=&#039;HKEY_LOCAL_MACHINE&#039;,
  @key=@InstanceLocation,
  @value_name=&#039;SQLPath&#039;,
  @value=@InstancePath OUTPUT
SELECT @InstancePath

USE [master]
GO
/****** Object:  Database [TestDB]    Script Date: 12/23/2011 04:56:32 ******/
CREATE DATABASE [TestDB] ON  PRIMARY 
( NAME = N&#039;TestDB&#039;, FILENAME = N&#039;&#039; + @InstancePath + N&#039;\DATA\TestDB.mdf&#039; , SIZE = 3328KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N&#039;TestDB_log&#039;, FILENAME = @InstancePath + N&#039;\DATA\TestDB_log.ldf&#039; , SIZE = 832KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [TestDB] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY(&#039;IsFullTextInstalled&#039;))
begin
EXEC [TestDB].[dbo].[sp_fulltext_database] @action = &#039;enable&#039;
end
GO
ALTER DATABASE [TestDB] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [TestDB] SET ANSI_NULLS OFF
GO
ALTER DATABASE [TestDB] SET ANSI_PADDING OFF
GO
ALTER DATABASE [TestDB] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [TestDB] SET ARITHABORT OFF
GO
ALTER DATABASE [TestDB] SET AUTO_CLOSE ON
GO
ALTER DATABASE [TestDB] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [TestDB] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [TestDB] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [TestDB] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [TestDB] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [TestDB] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [TestDB] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [TestDB] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [TestDB] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [TestDB] SET  DISABLE_BROKER
GO
ALTER DATABASE [TestDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [TestDB] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [TestDB] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [TestDB] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [TestDB] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [TestDB] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [TestDB] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [TestDB] SET  READ_WRITE
GO
ALTER DATABASE [TestDB] SET RECOVERY SIMPLE
GO
ALTER DATABASE [TestDB] SET  MULTI_USER
GO
ALTER DATABASE [TestDB] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [TestDB] SET DB_CHAINING OFF
GO
USE [TestDB]
GO


Error List
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near &#039;@InstancePath&#039;.
Msg 5011, Level 14, State 5, Line 1
User does not have permission to alter database &#039;TestDB&#039;, the database does not exist, or the database is not in a state that allows access checks.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Msg 5011, Level 14, State 5, Line 1

Thanks You Pinal]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
Here is my SQL Script to Create TESTDB. I Try to Create DB on SQL Server 2008 R2 But got Lots error Can you tell me what&#8217;s wrong. I am not expert on SQL Server. I can create DB Desing but I am tring to create DB Run-time on my Program. Here are code&#8230;.</p>
<p>DECLARE @InstanceName varchar(100),<br />
                @InstanceLocation varchar(100),<br />
                @InstancePath varchar(100)</p>
<p>SELECT @InstanceName = convert(varchar, ServerProperty(&#8216;InstanceName&#8217;))<br />
EXEC master..xp_regread @rootkey=&#8217;HKEY_LOCAL_MACHINE&#8217;,<br />
  @key=&#8217;Software\Microsoft\Microsoft SQL Server\Instance Names\SQL&#8217;,<br />
  @value_name=&#8217;SQLEXPRESS&#8217;,<br />
  @value=@InstanceLocation OUTPUT<br />
SELECT @InstanceLocation = &#8216;Software\Microsoft\Microsoft SQL Server\&#8217;+@InstanceLocation+&#8217;\Setup&#8217;</p>
<p>EXEC master..xp_regread @rootkey=&#8217;HKEY_LOCAL_MACHINE&#8217;,<br />
  @key=@InstanceLocation,<br />
  @value_name=&#8217;SQLPath&#8217;,<br />
  @value=@InstancePath OUTPUT<br />
SELECT @InstancePath</p>
<p>USE [master]<br />
GO<br />
/****** Object:  Database [TestDB]    Script Date: 12/23/2011 04:56:32 ******/<br />
CREATE DATABASE [TestDB] ON  PRIMARY<br />
( NAME = N&#8217;TestDB&#8217;, FILENAME = N&#8221; + @InstancePath + N&#8217;\DATA\TestDB.mdf&#8217; , SIZE = 3328KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )<br />
 LOG ON<br />
( NAME = N&#8217;TestDB_log&#8217;, FILENAME = @InstancePath + N&#8217;\DATA\TestDB_log.ldf&#8217; , SIZE = 832KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)<br />
GO<br />
ALTER DATABASE [TestDB] SET COMPATIBILITY_LEVEL = 100<br />
GO<br />
IF (1 = FULLTEXTSERVICEPROPERTY(&#8216;IsFullTextInstalled&#8217;))<br />
begin<br />
EXEC [TestDB].[dbo].[sp_fulltext_database] @action = &#8216;enable&#8217;<br />
end<br />
GO<br />
ALTER DATABASE [TestDB] SET ANSI_NULL_DEFAULT OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET ANSI_NULLS OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET ANSI_PADDING OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET ANSI_WARNINGS OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET ARITHABORT OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET AUTO_CLOSE ON<br />
GO<br />
ALTER DATABASE [TestDB] SET AUTO_CREATE_STATISTICS ON<br />
GO<br />
ALTER DATABASE [TestDB] SET AUTO_SHRINK OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET AUTO_UPDATE_STATISTICS ON<br />
GO<br />
ALTER DATABASE [TestDB] SET CURSOR_CLOSE_ON_COMMIT OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET CURSOR_DEFAULT  GLOBAL<br />
GO<br />
ALTER DATABASE [TestDB] SET CONCAT_NULL_YIELDS_NULL OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET NUMERIC_ROUNDABORT OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET QUOTED_IDENTIFIER OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET RECURSIVE_TRIGGERS OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET  DISABLE_BROKER<br />
GO<br />
ALTER DATABASE [TestDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET DATE_CORRELATION_OPTIMIZATION OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET TRUSTWORTHY OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET ALLOW_SNAPSHOT_ISOLATION OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET PARAMETERIZATION SIMPLE<br />
GO<br />
ALTER DATABASE [TestDB] SET READ_COMMITTED_SNAPSHOT OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET HONOR_BROKER_PRIORITY OFF<br />
GO<br />
ALTER DATABASE [TestDB] SET  READ_WRITE<br />
GO<br />
ALTER DATABASE [TestDB] SET RECOVERY SIMPLE<br />
GO<br />
ALTER DATABASE [TestDB] SET  MULTI_USER<br />
GO<br />
ALTER DATABASE [TestDB] SET PAGE_VERIFY CHECKSUM<br />
GO<br />
ALTER DATABASE [TestDB] SET DB_CHAINING OFF<br />
GO<br />
USE [TestDB]<br />
GO</p>
<p>Error List<br />
Msg 102, Level 15, State 1, Line 3<br />
Incorrect syntax near &#8216;@InstancePath&#8217;.<br />
Msg 5011, Level 14, State 5, Line 1<br />
User does not have permission to alter database &#8216;TestDB&#8217;, the database does not exist, or the database is not in a state that allows access checks.<br />
Msg 5069, Level 16, State 1, Line 1<br />
ALTER DATABASE statement failed.<br />
Msg 5011, Level 14, State 5, Line 1</p>
<p>Thanks You Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Megha Goyal</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-196030</link>
		<dc:creator><![CDATA[Megha Goyal]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 12:24:43 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-196030</guid>
		<description><![CDATA[Hi Pinal,

I have checked with the DB compatibility.. its 100 (using SQL Server 2008)

but still getting the same err : Msg 102, Level 15, State 1, Line 2
Incorrect syntax near &#039;,&#039;.

Can you pls help!! Below is my query..


ALTER PROCEDURE [Audit].[uspGetCardParameterAuditDtl]--3,123,126,122,129,&#039;01-11-2009&#039;,&#039;15-11-2010&#039;,&#039;&#039;,0,10,0
@EntityTypeID INT,
@DailyLimitID INT,
@CreditLimitID INT,
@MaxTrnLimitID INT,
@BalanceAmtID INT,
@StartDate NVARCHAR(20),
@EndDate NVARCHAR(20),
@ModifiedByUser NVARCHAR(30),
@PageIndex INT,
@PageSize INT,
@TotalRecord INT OUTPUT

AS  
BEGIN
	DECLARE @LowerBound INT,@UppperBound INT   
	DECLARE @Query NVARCHAR(4000),@ModifiedByQuery NVARCHAR(200),@ParamVal NVARCHAR(1000) 
	
	SELECT @LowerBound = @PageIndex * @PageSize     
	SELECT @UppperBound = @PageSize - 1 + @LowerBound  
	SELECT @StartDate=DATEADD(day,DATEDIFF(day,0,@StartDate),0)
	SELECT @EndDate=DATEADD(day,DATEDIFF(day,0,@EndDate),0)+1
	
	IF(LEN(@ModifiedByUser)&gt;0)  
	BEGIN  
		SET @ModifiedByQuery=&#039; AND U.UserName like &#039;&#039;%&#039;+@ModifiedByUser+&#039;%&#039;&#039;&#039;  
	END  
	ELSE  
	BEGIN  
		SET @ModifiedByQuery=&#039;&#039;  
	END 
	
	SELECT @Query=&#039;DECLARE @TmpTable TABLE (SNo INT, CardNumber BIGINT,DailyLimit NVARCHAR(100), CreditLimit NVARCHAR(100),
				MaxTrnLimit NVARCHAR(100),CCMSBalance NVARCHAR(100),ModifiedBy NVARCHAR(512),ModifyOn DATETIME); 
 
  
				DECLARE @CTEParams TABLE(ParameterName NVARCHAR(100),ParameterId INT,ParameterValue NVARCHAR(100),EntityID INT);     
   
				INSERT INTO @CTEParams   
				Select P.ParameterName , P.ParameterId , PE.ParameterValue, PE.EntityID      
					   from EntityParameterValues PE WITH(NOLOCK)    
					   inner join Parameter P WITH(NOLOCK) ON PE.ParameterId = P.ParameterId     
					   where PE.EntityTypeID=@EntityTypeIDVal;  
 
				 INSERT INTO @TmpTable  
				 Select ROW_NUMBER() OVER (ORDER BY CardNumber ASC) AS SNo  
						, C.CardNumber    
						, DailyLimit =  (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@DailyLimitIDVal and EntityId = C.CardId )    
						, CreditLimit = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@CreditLimitIDVal and EntityId = C.CardId)    
						, MaxTrnLimit = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@MaxTrnLimitIDVal and EntityId = C.CardId)    
						, CCMSBalance = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@BalanceAmtIDVal and EntityId = C.CardId)    
						,U.UserName AS ModifiedBy    
						,C.ModifiedDate AS ModifyOn    
				  From [Audit].[CardAudit] C WITH(NOLOCK)    
				  INNER JOIN aspnet_Users U WITH(NOLOCK)    
				  ON C.ModifiedBy=U.NumericUserId   
				  WHERE (C.CreatedDate&gt;=@StartDateVal AND C.CreatedDate&lt;@EndDateVAl)&#039;+@ModifiedByQuery+&#039;;&#039;+
				  
				&#039;SELECT * FROM [@TmpTable] WHERE SNo BETWEEN @LowerBoundVal AND @UppperBoundVal ORDER BY CardNumber;&#039; 
				
	SET @ParamVal=&#039;@EntityTypeIDVal INT,@StartDateVal NVARCHAR(20),@EndDateVal NVARCHAR(20),@LowerBoundVal INT,@UppperBoundVal INT,
				 @DailyLimitIDVal INT,@CreditLimitIDVal INT,@MaxTrnLimitIDVal INT,@BalanceAmtIDVal INT, ,@TotalRecordsOut INT OUT&#039;				
    
    Print @Query
    
    EXECUTE sp_executeSQL @Query,@ParamVal,@EntityTypeIDVal=@EntityTypeID,@StartDateVal=@StartDate,@EndDateVal=@EndDate,
						  @DailyLimitIDVal=@DailyLimitID,@CreditLimitIDVal=@CreditLimitID,@MaxTrnLimitIDVal=@MaxTrnLimitID,
						  @BalanceAmtIDVal=@BalanceAmtID,@LowerBoundVal=@LowerBound,@UppperBoundVal=@UppperBound,
						  @TotalRecordsOut=@TotalRecord OUTPUT
						  
	SELECT @TotalRecord					  			

END]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I have checked with the DB compatibility.. its 100 (using SQL Server 2008)</p>
<p>but still getting the same err : Msg 102, Level 15, State 1, Line 2<br />
Incorrect syntax near &#8216;,&#8217;.</p>
<p>Can you pls help!! Below is my query..</p>
<p>ALTER PROCEDURE [Audit].[uspGetCardParameterAuditDtl]&#8211;3,123,126,122,129,&#8217;01-11-2009&#8242;,&#8217;15-11-2010&#8242;,&#8221;,0,10,0<br />
@EntityTypeID INT,<br />
@DailyLimitID INT,<br />
@CreditLimitID INT,<br />
@MaxTrnLimitID INT,<br />
@BalanceAmtID INT,<br />
@StartDate NVARCHAR(20),<br />
@EndDate NVARCHAR(20),<br />
@ModifiedByUser NVARCHAR(30),<br />
@PageIndex INT,<br />
@PageSize INT,<br />
@TotalRecord INT OUTPUT</p>
<p>AS<br />
BEGIN<br />
	DECLARE @LowerBound INT,@UppperBound INT<br />
	DECLARE @Query NVARCHAR(4000),@ModifiedByQuery NVARCHAR(200),@ParamVal NVARCHAR(1000) </p>
<p>	SELECT @LowerBound = @PageIndex * @PageSize<br />
	SELECT @UppperBound = @PageSize &#8211; 1 + @LowerBound<br />
	SELECT @StartDate=DATEADD(day,DATEDIFF(day,0,@StartDate),0)<br />
	SELECT @EndDate=DATEADD(day,DATEDIFF(day,0,@EndDate),0)+1</p>
<p>	IF(LEN(@ModifiedByUser)&gt;0)<br />
	BEGIN<br />
		SET @ModifiedByQuery=&#8217; AND U.UserName like &#8221;%&#8217;+@ModifiedByUser+&#8217;%&#8221;&#8217;<br />
	END<br />
	ELSE<br />
	BEGIN<br />
		SET @ModifiedByQuery=&#8221;<br />
	END </p>
<p>	SELECT @Query=&#8217;DECLARE @TmpTable TABLE (SNo INT, CardNumber BIGINT,DailyLimit NVARCHAR(100), CreditLimit NVARCHAR(100),<br />
				MaxTrnLimit NVARCHAR(100),CCMSBalance NVARCHAR(100),ModifiedBy NVARCHAR(512),ModifyOn DATETIME); </p>
<p>				DECLARE @CTEParams TABLE(ParameterName NVARCHAR(100),ParameterId INT,ParameterValue NVARCHAR(100),EntityID INT);     </p>
<p>				INSERT INTO @CTEParams<br />
				Select P.ParameterName , P.ParameterId , PE.ParameterValue, PE.EntityID<br />
					   from EntityParameterValues PE WITH(NOLOCK)<br />
					   inner join Parameter P WITH(NOLOCK) ON PE.ParameterId = P.ParameterId<br />
					   where PE.EntityTypeID=@EntityTypeIDVal;  </p>
<p>				 INSERT INTO @TmpTable<br />
				 Select ROW_NUMBER() OVER (ORDER BY CardNumber ASC) AS SNo<br />
						, C.CardNumber<br />
						, DailyLimit =  (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@DailyLimitIDVal and EntityId = C.CardId )<br />
						, CreditLimit = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@CreditLimitIDVal and EntityId = C.CardId)<br />
						, MaxTrnLimit = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@MaxTrnLimitIDVal and EntityId = C.CardId)<br />
						, CCMSBalance = (Select ISNULL(ParameterValue,0) from @CTEParams where ParameterId =@BalanceAmtIDVal and EntityId = C.CardId)<br />
						,U.UserName AS ModifiedBy<br />
						,C.ModifiedDate AS ModifyOn<br />
				  From [Audit].[CardAudit] C WITH(NOLOCK)<br />
				  INNER JOIN aspnet_Users U WITH(NOLOCK)<br />
				  ON C.ModifiedBy=U.NumericUserId<br />
				  WHERE (C.CreatedDate&gt;=@StartDateVal AND C.CreatedDate&lt;@EndDateVAl)&#039;+@ModifiedByQuery+&#039;;&#039;+</p>
<p>				&#039;SELECT * FROM [@TmpTable] WHERE SNo BETWEEN @LowerBoundVal AND @UppperBoundVal ORDER BY CardNumber;&#039; </p>
<p>	SET @ParamVal=&#039;@EntityTypeIDVal INT,@StartDateVal NVARCHAR(20),@EndDateVal NVARCHAR(20),@LowerBoundVal INT,@UppperBoundVal INT,<br />
				 @DailyLimitIDVal INT,@CreditLimitIDVal INT,@MaxTrnLimitIDVal INT,@BalanceAmtIDVal INT, ,@TotalRecordsOut INT OUT&#039;				</p>
<p>    Print @Query</p>
<p>    EXECUTE sp_executeSQL @Query,@ParamVal,@EntityTypeIDVal=@EntityTypeID,@StartDateVal=@StartDate,@EndDateVal=@EndDate,<br />
						  @DailyLimitIDVal=@DailyLimitID,@CreditLimitIDVal=@CreditLimitID,@MaxTrnLimitIDVal=@MaxTrnLimitID,<br />
						  @BalanceAmtIDVal=@BalanceAmtID,@LowerBoundVal=@LowerBound,@UppperBoundVal=@UppperBound,<br />
						  @TotalRecordsOut=@TotalRecord OUTPUT</p>
<p>	SELECT @TotalRecord					  			</p>
<p>END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-191497</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 10:05:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-191497</guid>
		<description><![CDATA[Are you trying to return empty string?

Use this

declare @ls_sql as varchar(500)
declare @ls_value as varchar(10)
set @ls_value = &#039;&#039;&#039;&#039;&#039;&#039;
set @ls_sql = &#039;select &#039; + @ls_value
execute(@ls_sql)


Also refer this to understand how single quotes work in dynamic sql
http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx]]></description>
		<content:encoded><![CDATA[<p>Are you trying to return empty string?</p>
<p>Use this</p>
<p>declare @ls_sql as varchar(500)<br />
declare @ls_value as varchar(10)<br />
set @ls_value = &#8221;&#8221;&#8221;<br />
set @ls_sql = &#8216;select &#8216; + @ls_value<br />
execute(@ls_sql)</p>
<p>Also refer this to understand how single quotes work in dynamic sql<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: romnick</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-190696</link>
		<dc:creator><![CDATA[romnick]]></dc:creator>
		<pubDate>Tue, 08 Nov 2011 08:28:53 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-190696</guid>
		<description><![CDATA[declare @ls_sql as varchar(500)
declare @ls_value as varchar(10)
set @ls_value = &#039;&#039;
set @ls_sql = &#039;select  &#039; + @ls_value 
execute(@ls_sql)

why this is isn&#039;t working? tnx for the help..]]></description>
		<content:encoded><![CDATA[<p>declare @ls_sql as varchar(500)<br />
declare @ls_value as varchar(10)<br />
set @ls_value = &#8221;<br />
set @ls_sql = &#8216;select  &#8216; + @ls_value<br />
execute(@ls_sql)</p>
<p>why this is isn&#8217;t working? tnx for the help..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geetanjali</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-166755</link>
		<dc:creator><![CDATA[Geetanjali]]></dc:creator>
		<pubDate>Fri, 09 Sep 2011 07:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-166755</guid>
		<description><![CDATA[If table does not exist in db1 

Select * into  Table2 fromDB2..Table2]]></description>
		<content:encoded><![CDATA[<p>If table does not exist in db1 </p>
<p>Select * into  Table2 fromDB2..Table2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geetanjali</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-166752</link>
		<dc:creator><![CDATA[Geetanjali]]></dc:creator>
		<pubDate>Fri, 09 Sep 2011 07:12:24 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-166752</guid>
		<description><![CDATA[suppose two database are DB1, DB2

Insert into Table1 
Select * from DB2..Table2]]></description>
		<content:encoded><![CDATA[<p>suppose two database are DB1, DB2</p>
<p>Insert into Table1<br />
Select * from DB2..Table2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zeeshan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-162979</link>
		<dc:creator><![CDATA[zeeshan]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 19:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-162979</guid>
		<description><![CDATA[Hi Pinaldave,
i read how we can remove the error that asking for upgrade etc but i am trying to copy one table from one database to other database on same SQL so how can we edit this syntax in the graphicaly]]></description>
		<content:encoded><![CDATA[<p>Hi Pinaldave,<br />
i read how we can remove the error that asking for upgrade etc but i am trying to copy one table from one database to other database on same SQL so how can we edit this syntax in the graphicaly</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-140226</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 10:58:03 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-140226</guid>
		<description><![CDATA[use cast or convert function]]></description>
		<content:encoded><![CDATA[<p>use cast or convert function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: umashankar.B</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-138862</link>
		<dc:creator><![CDATA[umashankar.B]]></dc:creator>
		<pubDate>Sat, 04 Jun 2011 11:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-138862</guid>
		<description><![CDATA[how can we convert datatype while inserting values using stored procedure]]></description>
		<content:encoded><![CDATA[<p>how can we convert datatype while inserting values using stored procedure</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: umashankar.B</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-138857</link>
		<dc:creator><![CDATA[umashankar.B]]></dc:creator>
		<pubDate>Sat, 04 Jun 2011 11:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-138857</guid>
		<description><![CDATA[procedure or function expects a parameter which was not supplied      

    but i checked the procedure ,aspx.cs ,buisness layer and also data acess layer all are correct  



one more problem in sql procedure which has one column of date type while executing 1st time all the values are passed
but for 2nd time an error is occured ie  error on date type converting nvarchar to date type]]></description>
		<content:encoded><![CDATA[<p>procedure or function expects a parameter which was not supplied      </p>
<p>    but i checked the procedure ,aspx.cs ,buisness layer and also data acess layer all are correct  </p>
<p>one more problem in sql procedure which has one column of date type while executing 1st time all the values are passed<br />
but for 2nd time an error is occured ie  error on date type converting nvarchar to date type</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lavanya</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-138314</link>
		<dc:creator><![CDATA[lavanya]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 05:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-138314</guid>
		<description><![CDATA[create table products
	(prodid int identity (100, 1) constraint products_pk primary key,
 	 prodname varchar(30) constraint products_prodname_nn not null,
	 price money constraint products_price_chk check(price &gt;= 0),
	 qoh int default 0 ,
	 remarks varchar(100),
	 catcode varchar(10) references  categories (catcode) on delete casecade );


here iam getting error like this incorrect syntax near &#039; )&#039;.
so please help me how to rectify this error]]></description>
		<content:encoded><![CDATA[<p>create table products<br />
	(prodid int identity (100, 1) constraint products_pk primary key,<br />
 	 prodname varchar(30) constraint products_prodname_nn not null,<br />
	 price money constraint products_price_chk check(price &gt;= 0),<br />
	 qoh int default 0 ,<br />
	 remarks varchar(100),<br />
	 catcode varchar(10) references  categories (catcode) on delete casecade );</p>
<p>here iam getting error like this incorrect syntax near &#8216; )&#8217;.<br />
so please help me how to rectify this error</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-133824</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 13:22:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-133824</guid>
		<description><![CDATA[Replace SET @ttnm = (&#039;select * from &#039; + @tblnam + &#039;where pid = &#039; + @pid)


with

SET @ttnm = &#039;select * from &#039; + @tblnam + &#039;where pid = &#039; + @pid]]></description>
		<content:encoded><![CDATA[<p>Replace SET @ttnm = (&#8216;select * from &#8216; + @tblnam + &#8216;where pid = &#8216; + @pid)</p>
<p>with</p>
<p>SET @ttnm = &#8216;select * from &#8216; + @tblnam + &#8216;where pid = &#8216; + @pid</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hema</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-133589</link>
		<dc:creator><![CDATA[hema]]></dc:creator>
		<pubDate>Mon, 09 May 2011 12:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-133589</guid>
		<description><![CDATA[0 down vote favorite
	

I have created a store procedure for updating the patient name in multiple tables. When I execute it, shows the error like

    Server: Msg 170, Level 15, State 1,
    Line 1 Line 1: Incorrect syntax near &#039;=&#039;.

And my coding is


create procedure uppatname @pid varchar(150),@pname varchar(150)
as begin
  declare @i as integer
  declare @i1 as integer
  declare @ttnm  as varchar(100)
  declare @tblnam as varchar(100)

  drop table tbname
  SELECT IDENTITY(int, 1,1) AS RowNumber, table_name  
    INTO tbname  
    FROM information_schema.columns 
    WHERE column_name = &#039;pid&#039; 
      AND table_catalog = &#039;hospital&#039; 
      AND table_name NOT LIKE &#039;T%&#039;

  SET @i = (select count(*) from information_schema.columns 
            where column_name=&#039;pid&#039; and table_catalog=&#039;hospital&#039; 
              and table_name not like &#039;T%&#039;)

  SET @i1 = 1

  WHILE @i1 &lt;= @i
  BEGIN
     SET @tblnam = (select table_name  from tbname where rownumber = @i1)
     SET @ttnm = (&#039;select  * from &#039; + @tblnam + &#039;where pid = &#039; + @pid)
     EXEC (@ttnm)
     SET @i1 = @i1 + 1
  END
END



kindly help me]]></description>
		<content:encoded><![CDATA[<p>0 down vote favorite</p>
<p>I have created a store procedure for updating the patient name in multiple tables. When I execute it, shows the error like</p>
<p>    Server: Msg 170, Level 15, State 1,<br />
    Line 1 Line 1: Incorrect syntax near &#8216;=&#8217;.</p>
<p>And my coding is</p>
<p>create procedure uppatname @pid varchar(150),@pname varchar(150)<br />
as begin<br />
  declare @i as integer<br />
  declare @i1 as integer<br />
  declare @ttnm  as varchar(100)<br />
  declare @tblnam as varchar(100)</p>
<p>  drop table tbname<br />
  SELECT IDENTITY(int, 1,1) AS RowNumber, table_name<br />
    INTO tbname<br />
    FROM information_schema.columns<br />
    WHERE column_name = &#8216;pid&#8217;<br />
      AND table_catalog = &#8216;hospital&#8217;<br />
      AND table_name NOT LIKE &#8216;T%&#8217;</p>
<p>  SET @i = (select count(*) from information_schema.columns<br />
            where column_name=&#8217;pid&#8217; and table_catalog=&#8217;hospital&#8217;<br />
              and table_name not like &#8216;T%&#8217;)</p>
<p>  SET @i1 = 1</p>
<p>  WHILE @i1 &lt;= @i<br />
  BEGIN<br />
     SET @tblnam = (select table_name  from tbname where rownumber = @i1)<br />
     SET @ttnm = (&#039;select  * from &#039; + @tblnam + &#039;where pid = &#039; + @pid)<br />
     EXEC (@ttnm)<br />
     SET @i1 = @i1 + 1<br />
  END<br />
END</p>
<p>kindly help me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bala Palani</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-122594</link>
		<dc:creator><![CDATA[Bala Palani]]></dc:creator>
		<pubDate>Wed, 09 Mar 2011 21:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-122594</guid>
		<description><![CDATA[Great,

It worked for me. I was trying to create a UDA using SQL clr and I was getting the exact same error and after executing the &quot;EXEC sp_dbcmptlevel &#039;db_name&#039;, 100 &quot; I was able to deploy the UDA in VS successfully.

Thanks Pinal.

regards,
Bala]]></description>
		<content:encoded><![CDATA[<p>Great,</p>
<p>It worked for me. I was trying to create a UDA using SQL clr and I was getting the exact same error and after executing the &#8220;EXEC sp_dbcmptlevel &#8216;db_name&#8217;, 100 &#8221; I was able to deploy the UDA in VS successfully.</p>
<p>Thanks Pinal.</p>
<p>regards,<br />
Bala</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vijay</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-114574</link>
		<dc:creator><![CDATA[vijay]]></dc:creator>
		<pubDate>Thu, 27 Jan 2011 04:41:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-114574</guid>
		<description><![CDATA[Hi Pinal,

Thanks for your help. Whenever I face any issue with Sql server and see your website, I will feel relaxed( I am sure I got the solution)

Thanks again
Vijay]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Thanks for your help. Whenever I face any issue with Sql server and see your website, I will feel relaxed( I am sure I got the solution)</p>
<p>Thanks again<br />
Vijay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-114056</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 25 Jan 2011 08:55:03 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-114056</guid>
		<description><![CDATA[BACKUP DATABASE [1310_dB]
TO DISK = ‘C:\Backuprestore\1310_db1.bak’;
WITH FORMAT;


It is not a good practice to name an object name starting with a number]]></description>
		<content:encoded><![CDATA[<p>BACKUP DATABASE [1310_dB]<br />
TO DISK = ‘C:\Backuprestore\1310_db1.bak’;<br />
WITH FORMAT;</p>
<p>It is not a good practice to name an object name starting with a number</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vijay</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-113755</link>
		<dc:creator><![CDATA[vijay]]></dc:creator>
		<pubDate>Mon, 24 Jan 2011 07:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-113755</guid>
		<description><![CDATA[when I run command below
BACKUP DATABASE 1310_dB
  TO DISK = &#039;C:\Backuprestore\1310_db1.bak&#039;;
   WITH FORMAT;
GO

I am getting message as
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near &#039;1310&#039;.


Please provide solution also let me know how to restore back up from file or file group]]></description>
		<content:encoded><![CDATA[<p>when I run command below<br />
BACKUP DATABASE 1310_dB<br />
  TO DISK = &#8216;C:\Backuprestore\1310_db1.bak&#8217;;<br />
   WITH FORMAT;<br />
GO</p>
<p>I am getting message as<br />
Msg 102, Level 15, State 1, Line 1<br />
Incorrect syntax near &#8217;1310&#8242;.</p>
<p>Please provide solution also let me know how to restore back up from file or file group</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kritya Kumar</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-84653</link>
		<dc:creator><![CDATA[Kritya Kumar]]></dc:creator>
		<pubDate>Thu, 19 Aug 2010 15:36:14 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-84653</guid>
		<description><![CDATA[getting this error can u fix it ?
 
Incorrect syntax near &#039;=&#039;.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near &#039;=&#039;.

Source Error:

Line 53:         string del = &quot;delete from tbluttam_allimage where id=&quot; + DataList1.DataKeys[e.Item.ItemIndex];
Line 54:         SqlCommand cmd = new SqlCommand(del, con);
Line 55:         cmd.ExecuteNonQuery();
Line 56:         heat();
Line 57: 


Source File: c:\inetpub\vhosts\uttamindustries.com\httpdocs\admin_uttam\manageimage.aspx.cs    Line: 55

Stack Trace:

[SqlException (0x80131904): Incorrect syntax near &#039;=&#039;.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +317
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   admin_uttam_manageimage.DataList1_DeleteCommand(Object source, DataListCommandEventArgs e) in c:\inetpub\vhosts\uttamindustries.com\httpdocs\admin_uttam\manageimage.aspx.cs:55
   System.Web.UI.WebControls.DataList.OnDeleteCommand(DataListCommandEventArgs e) +108
   System.Web.UI.WebControls.DataList.OnBubbleEvent(Object source, EventArgs e) +8736452
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.DataListItem.OnBubbleEvent(Object source, EventArgs e) +123
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565]]></description>
		<content:encoded><![CDATA[<p>getting this error can u fix it ?</p>
<p>Incorrect syntax near &#8216;=&#8217;.<br />
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
<p>Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near &#8216;=&#8217;.</p>
<p>Source Error:</p>
<p>Line 53:         string del = &#8220;delete from tbluttam_allimage where id=&#8221; + DataList1.DataKeys[e.Item.ItemIndex];<br />
Line 54:         SqlCommand cmd = new SqlCommand(del, con);<br />
Line 55:         cmd.ExecuteNonQuery();<br />
Line 56:         heat();<br />
Line 57: </p>
<p>Source File: c:\inetpub\vhosts\uttamindustries.com\httpdocs\admin_uttam\manageimage.aspx.cs    Line: 55</p>
<p>Stack Trace:</p>
<p>[SqlException (0x80131904): Incorrect syntax near '='.]<br />
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826<br />
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747<br />
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194<br />
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392<br />
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192<br />
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +317<br />
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137<br />
   admin_uttam_manageimage.DataList1_DeleteCommand(Object source, DataListCommandEventArgs e) in c:\inetpub\vhosts\uttamindustries.com\httpdocs\admin_uttam\manageimage.aspx.cs:55<br />
   System.Web.UI.WebControls.DataList.OnDeleteCommand(DataListCommandEventArgs e) +108<br />
   System.Web.UI.WebControls.DataList.OnBubbleEvent(Object source, EventArgs e) +8736452<br />
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37<br />
   System.Web.UI.WebControls.DataListItem.OnBubbleEvent(Object source, EventArgs e) +123<br />
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37<br />
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118<br />
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135<br />
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10<br />
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13<br />
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175<br />
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunita</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-83813</link>
		<dc:creator><![CDATA[sunita]]></dc:creator>
		<pubDate>Thu, 12 Aug 2010 08:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-83813</guid>
		<description><![CDATA[Is this website for demo only!!!!!!!!

what are u doing yaar]]></description>
		<content:encoded><![CDATA[<p>Is this website for demo only!!!!!!!!</p>
<p>what are u doing yaar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunita</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-83811</link>
		<dc:creator><![CDATA[sunita]]></dc:creator>
		<pubDate>Thu, 12 Aug 2010 07:51:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-83811</guid>
		<description><![CDATA[It&#039;s urgnt,  

client is over-head!!!!!!!!!!]]></description>
		<content:encoded><![CDATA[<p>It&#8217;s urgnt,  </p>
<p>client is over-head!!!!!!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunita</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-83810</link>
		<dc:creator><![CDATA[sunita]]></dc:creator>
		<pubDate>Thu, 12 Aug 2010 07:46:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-83810</guid>
		<description><![CDATA[SELECT   TOP (100) PERCENT b.bill_no, b.date, b.Amount, c.bill_no AS
Expr3, c.current_dat, em.date_adv_pay, em.adv_pay, ex.Date_of_expense,ex.Amount AS Expr5, ep.Date_of_Expense AS Expr6,
ep.Amount AS Expr7, en.bill_no AS Expr1,en.date AS Expr2, en.total, c.total AS Expr4
FROM            bill_receive_entry b,
                cus_pay_detail c,
                emp_pay em,
                expense_personnel ex,
                expense_prod ep,
                enlarge en
where         b.date(+)=c.current_dat
and           em.date_adv_pay=c.current_dat(+)
and           ex.Date_of_expense = em.date_adv_pay(+)
and           ep.Date_of_Expense = ex.Date_of_expense (+)
and            en.date = ep.Date_of_Expense(+)
 ORDER BY c.current_dat, c.bill_no, b.bill_no, em.date_adv_pay,ex.Date_of_expense, ep.Date_of_Expense, en.date

But the error is coming like, I am not able to detect the prob. Actually I am a fresher in sql. so plz do help it,s urgnt
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near &#039;)&#039;.]]></description>
		<content:encoded><![CDATA[<p>SELECT   TOP (100) PERCENT b.bill_no, b.date, b.Amount, c.bill_no AS<br />
Expr3, c.current_dat, em.date_adv_pay, em.adv_pay, ex.Date_of_expense,ex.Amount AS Expr5, ep.Date_of_Expense AS Expr6,<br />
ep.Amount AS Expr7, en.bill_no AS Expr1,en.date AS Expr2, en.total, c.total AS Expr4<br />
FROM            bill_receive_entry b,<br />
                cus_pay_detail c,<br />
                emp_pay em,<br />
                expense_personnel ex,<br />
                expense_prod ep,<br />
                enlarge en<br />
where         b.date(+)=c.current_dat<br />
and           em.date_adv_pay=c.current_dat(+)<br />
and           ex.Date_of_expense = em.date_adv_pay(+)<br />
and           ep.Date_of_Expense = ex.Date_of_expense (+)<br />
and            en.date = ep.Date_of_Expense(+)<br />
 ORDER BY c.current_dat, c.bill_no, b.bill_no, em.date_adv_pay,ex.Date_of_expense, ep.Date_of_Expense, en.date</p>
<p>But the error is coming like, I am not able to detect the prob. Actually I am a fresher in sql. so plz do help it,s urgnt<br />
Msg 102, Level 15, State 1, Line 10<br />
Incorrect syntax near &#8216;)&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MS</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-82896</link>
		<dc:creator><![CDATA[MS]]></dc:creator>
		<pubDate>Tue, 03 Aug 2010 19:51:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-82896</guid>
		<description><![CDATA[Hi,
I am having kind of similar issue at my client. They are runnign their database on Microsoft Dynamics NAV with SQL server option. But when user tries to enter a sales order in NAV they get the following SQL error - 

102,&quot;42000&quot;[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near &#039;{&#039;. 

they are on SQL server 2008 and Microsoft dynamics NAV 4SP1 with NAV5.0 SP1 executables.

Thanks
Meenakshi]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
I am having kind of similar issue at my client. They are runnign their database on Microsoft Dynamics NAV with SQL server option. But when user tries to enter a sales order in NAV they get the following SQL error &#8211; </p>
<p>102,&#8221;42000&#8243;[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near &#8216;{&#8216;. </p>
<p>they are on SQL server 2008 and Microsoft dynamics NAV 4SP1 with NAV5.0 SP1 executables.</p>
<p>Thanks<br />
Meenakshi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shravya</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-72116</link>
		<dc:creator><![CDATA[Shravya]]></dc:creator>
		<pubDate>Fri, 21 May 2010 20:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-72116</guid>
		<description><![CDATA[Hi Pinal,

Would you please help me fixing this error. 

&quot;(2 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near &#039;,&#039;.

(1 row(s) affected)

(1 row(s) affected)&quot;

The Store proc is as follows
------------------------------------------------------
Create Database Bank
Go
Use Bank
go
Create table Account([ID] int, Name Varchar(100), 
AccountNo varchar(100), Balance money)
Go
Create table logtable (id int identity(1,1), 
	Query varchar(1000), 
	Importeddate datetime default getdate())
Go

Create procedure usp_ImportMultipleFiles @filepath varchar(500), 
	@pattern varchar(100), @TableName varchar(128)
as
set quoted_identifier off
declare @query varchar(1000)
declare @max1 int
declare @count1 int
Declare @filename varchar(100)
set @count1 =0
create table #x (name varchar(200))
set @query =&#039;master.dbo.xp_cmdshell &quot;dir &#039;+@filepath+@pattern +&#039; /b&quot;&#039;
insert #x exec (@query)
delete from #x where name is NULL
select identity(int,1,1) as ID, name into #y from #x 
drop table #x
set @max1 = (select max(ID) from #y)
--print @max1
--print @count1
While @count1 &lt;= @max1
begin
set @count1=@count1+1
set @filename = (select name from #y where [id] = @count1)
set @Query =&#039;BULK INSERT &#039;+ @Tablename + &#039; FROM &quot;&#039;+ @Filepath+@Filename+&#039;&quot; 
	WITH ( FIELDTERMINATOR = &quot;,&quot;,ROWTERMINATOR = &quot;\n&quot;)&#039;
--print @query
exec (@query)
insert into logtable (query) select @query
end

drop table #y

Executing the proc----
Exec usp_ImportMultipleFiles &#039;c:\myimport\&#039;, &#039;*.csv&#039;, &#039;Account&#039;
-----------------------------------------]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Would you please help me fixing this error. </p>
<p>&#8220;(2 row(s) affected)</p>
<p>(1 row(s) affected)</p>
<p>(1 row(s) affected)<br />
Msg 102, Level 15, State 1, Line 2<br />
Incorrect syntax near &#8216;,&#8217;.</p>
<p>(1 row(s) affected)</p>
<p>(1 row(s) affected)&#8221;</p>
<p>The Store proc is as follows<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Create Database Bank<br />
Go<br />
Use Bank<br />
go<br />
Create table Account([ID] int, Name Varchar(100),<br />
AccountNo varchar(100), Balance money)<br />
Go<br />
Create table logtable (id int identity(1,1),<br />
	Query varchar(1000),<br />
	Importeddate datetime default getdate())<br />
Go</p>
<p>Create procedure usp_ImportMultipleFiles @filepath varchar(500),<br />
	@pattern varchar(100), @TableName varchar(128)<br />
as<br />
set quoted_identifier off<br />
declare @query varchar(1000)<br />
declare @max1 int<br />
declare @count1 int<br />
Declare @filename varchar(100)<br />
set @count1 =0<br />
create table #x (name varchar(200))<br />
set @query =&#8217;master.dbo.xp_cmdshell &#8220;dir &#8216;+@filepath+@pattern +&#8217; /b&#8221;&#8216;<br />
insert #x exec (@query)<br />
delete from #x where name is NULL<br />
select identity(int,1,1) as ID, name into #y from #x<br />
drop table #x<br />
set @max1 = (select max(ID) from #y)<br />
&#8211;print @max1<br />
&#8211;print @count1<br />
While @count1 &lt;= @max1<br />
begin<br />
set @count1=@count1+1<br />
set @filename = (select name from #y where [id] = @count1)<br />
set @Query =&#039;BULK INSERT &#039;+ @Tablename + &#039; FROM &quot;&#039;+ @Filepath+@Filename+&#039;&quot;<br />
	WITH ( FIELDTERMINATOR = &quot;,&quot;,ROWTERMINATOR = &quot;\n&quot;)&#039;<br />
&#8211;print @query<br />
exec (@query)<br />
insert into logtable (query) select @query<br />
end</p>
<p>drop table #y</p>
<p>Executing the proc&#8212;-<br />
Exec usp_ImportMultipleFiles &#039;c:\myimport\&#039;, &#039;*.csv&#039;, &#039;Account&#039;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-63547</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Tue, 23 Mar 2010 09:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-63547</guid>
		<description><![CDATA[You need to double the single quotes
http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx]]></description>
		<content:encoded><![CDATA[<p>You need to double the single quotes<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/#comment-59996</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Wed, 20 Jan 2010 11:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1411#comment-59996</guid>
		<description><![CDATA[Hello Steve,

USER is a keyword and SQL Server take it as a keyword. While parsing the statement it founds the keyword at wrong place (FROM clause) and returns error. When we write [USER], it takes it as an identifier.

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hello Steve,</p>
<p>USER is a keyword and SQL Server take it as a keyword. While parsing the statement it founds the keyword at wrong place (FROM clause) and returns error. When we write [USER], it takes it as an identifier.</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
</channel>
</rss>

