Showing posts with label executing. Show all posts
Showing posts with label executing. Show all posts

Wednesday, March 28, 2012

Incorrect use of the xml data type method ''modify''. A non-mutator method is expected in th

Hi,

I'm getting an error when I'm executing the follwing query in SQL Server 2005

declare @.xml xml

set @.xml = '<ROOT>

<Customer CustomerID="VINET" ContactName="Paul Henriot">

<Order OrderID="10248" CustomerID="VINET" EmployeeID="5"

OrderDate="1996-07-04T00:00:00">

<OrderDetail ProductID="11" Quantity="12"/>

<OrderDetail ProductID="42" Quantity="10"/>

</Order>

</Customer>

<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">

<Order OrderID="10283" CustomerID="LILAS" EmployeeID="3"

OrderDate="1996-08-16T00:00:00">

<OrderDetail ProductID="72" Quantity="3"/>

</Order>

</Customer>

</ROOT>'

if @.xml.exist('//Order[OrderID="10283"]')=0

begin

set @.xml = @.xml.modify('insert <Order OrderID="10284" CustomerID="LILAS" EmployeeID="3"

OrderDate="1996-08-16T00:00:00"></Order> after //Order[@.OrderID="10283"]')

select @.xml

end

The error is

Incorrect use of the xml data type method 'modify'. A non-mutator method is expected in this context.

Please give me the answare

Regards,

Koustav

Here is a corrected, working version that simply uses SET @.x.modify:

Code Snippet

declare @.xml xml

set @.xml = '<ROOT>

<Customer CustomerID="VINET" ContactName="Paul Henriot">

<Order OrderID="10248" CustomerID="VINET" EmployeeID="5"

OrderDate="1996-07-04T00:00:00">

<OrderDetail ProductID="11" Quantity="12"/>

<OrderDetail ProductID="42" Quantity="10"/>

</Order>

</Customer>

<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">

<Order OrderID="10283" CustomerID="LILAS" EmployeeID="3"

OrderDate="1996-08-16T00:00:00">

<OrderDetail ProductID="72" Quantity="3"/>

</Order>

</Customer>

</ROOT>'

if @.xml.exist('//Order[OrderID="10283"]')=0

begin

set @.xml.modify('

insert <Order OrderID="10284" CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00"></Order> after (//Order[@.OrderID="10283"])[1]')

select @.xml

end

|||

Thanx Martin its now working fine.

I've another query How will I get an attribute's value of a particuler node?

say for example

I've @.xml as xml document and I've find out the following node using xquery

<Order OrderID="10284" CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00"></Order>

Now I want to check if OrderDate >= "1996-08-16" then insert some OrderDetail.

How will I read this OrderDate attribute's value.

Please help me.

Regards,

Koustav

|||

I hope the following example helps:

Code Snippet

DECLARE @.x xml;

SET @.x = '

<Orders>

<Order OrderID="10284" CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00"></Order>

<Order OrderID="10285" CustomerID="Someone" EmployeeID="3" OrderDate="1994-08-16T00:00:00"></Order>

</Orders>';

IF @.x.exist('

/Orders/Order[@.OrderDate >= "1996-08-16T00:00:00"]

') = 1

BEGIN

SET @.x.modify('

insert <OrderDetail Product="Something"/>

into (/Orders/Order[@.OrderDate >= "1996-08-16T00:00:00"])[1]

');

SELECT @.x

END

|||Thanx a lot Martin. It perfectly working.

|||

Continuing the above example I'm facing anaother problem.

Instead of insert xml node I'm trying to replace an attribute's value. I've written

if @.xml.exist('/Customer/Order[@.OrderID="10283"]')=0

begin

--set @.xml.modify('insert <Order OrderID="10284" CustomerID="LILAS" EmployeeID="3"

-- OrderDate="1996-08-16T00:00:00"></Order> after (//Order[@.OrderID="10283"])[1]')

set @.xml.modify('declare namespace ns="http://myOrder";

replace value of (//nsSurpriserder[@.OrderID="10283"]/OrderDetail/@.Quantity)[1] with 4')

select @.xml

end

The XML is untyped xml. There are no such schema named "myOrder" but if I'm not giving the line "declare namespace ns='http://myOrder';" its throwing error.

Now the problem is. this query is executing but the value dose not replace.

Please give me the solution.

|||

The following sample code works flawlessly for me, the Quantity attribute value is changed from 3 to 4:

Code Snippet

DECLARE @.xml xml;

SET @.xml = '<Customer>

<Order OrderID="10283">

<OrderDetail Quantity="3"/>

</Order>

</Customer>';

IF @.xml.exist('/Customer/Order[@.OrderID="10283"]') = 1

BEGIN

SET @.xml.modify('

replace value of (//Order[@.OrderID="10283"]/OrderDetail/@.Quantity)[1] with 4

');

END;

SELECT @.xml;

|||

Thank you Martin, I don't know why it was not running in my environment. But fortunatly now it aslo running in my machine. Thanks for your help.

Martine, I'm also facing another problem.

...

...

declare @.CID varchar(10)

DECLARE C1 CURSOR FOR SELECT ID FROM select customerID from customer

OPEN C1;

FETCH NEXT FROM C1 into @.CID

WHILE @.@.FETCH_STATUS = 0

BEGIN

set @.queryString = 'for $cust in //Customer where $cust/@.CustmerID = "' + @.CID + '" return $cust'

--set @.detail = @.xml.query('for $cust in //Customer where $cust/@.CustmerID = "' + @.CID + '" return $cust')

set @.detail = @.xml.query(@.queryString)

select @.detail

select @.queryString

FETCH NEXT FROM C1 into @.CID

END

....

...

Its showing an error

The argument 1 of the xml data type method "query" must be a string literal.

That means query() can't execute a string veriable. But I've to meet this type of requirment. From above XML I want to read each node then doing some processing into subnodes and then put the value into a table. So first I've to process 1st customer node and its child nodes then shift to 2nd customer and so on.

Please help me how will I proceed.

|||

You can use sql:variable as follows:

Code Snippet

DECLARE @.CID nvarchar(10);

SET @.CID = '1234';

DECLARE @.xml xml;

SET @.xml = '<root>

<Customer CustomerId="1233"/>

<Customer CustomerId="1234"/>

</root>'

SELECT @.xml.query('

for $c in root/Customer

where $c/@.CustomerId = sql:variable("@.CID")

return $c

');

|||

Hi,

I have problem in replacing set of elements with text.

declare @.dtToday datetime

, @.input xml

set @.dtToday = getdate()

-- here is my input XML

set @.input = '<TsfDesc>

<physical_to_loc>1000004</physical_to_loc>

<to_loc_type>S</to_loc_type>

<pick_not_before_date>

<year>2001</year>

<month>03</month>

<day>09</day>

<hour>00</hour>

<minute>00</minute>

<second>00</second>

</pick_not_before_date>

<to_loc_type>S</to_loc_type>

</TsfDesc>'

I would like to get the output as shown below

'<TsfDesc>

<physical_to_loc>1000004</physical_to_loc>

<to_loc_type>S</to_loc_type>

<pick_not_before_date>03/09/2001 00:00:00

</pick_not_before_date>

<to_loc_type>S</to_loc_type>

</TsfDesc>'

would you please help me?

Thanks in advance.

Meeran.

|||

Here is a solution using several steps:

Code Snippet

DECLARE @.input xml;

set @.input = '<TsfDesc>

<physical_to_loc>1000004</physical_to_loc>

<to_loc_type>S</to_loc_type>

<pick_not_before_date>

<year>2001</year>

<month>03</month>

<day>09</day>

<hour>00</hour>

<minute>00</minute>

<second>00</second>

</pick_not_before_date>

<to_loc_type>S</to_loc_type>

</TsfDesc>';

DECLARE @.date nvarchar(19);

SET @.date = @.input.value('

concat((TsfDesc/pick_not_before_date/day)[1], "/", (TsfDesc/pick_not_before_date/month)[1], "/", (TsfDesc/pick_not_before_date/year)[1], " ", (TsfDesc/pick_not_before_date/hour)[1], ":", (TsfDesc/pick_not_before_date/minute)[1], ":", (TsfDesc/pick_not_before_date/second)[1])

', 'nvarchar(19)');

SET @.input.modify('

delete TsfDesc/pick_not_before_date/node()

')

SET @.input.modify('

insert text{sql:variable("@.date")}

into (TsfDesc/pick_not_before_date)[1]

');

SELECT @.input;

|||

Thanks a lot Martin, for your prompt response.

Monday, March 26, 2012

Incorrect syntax near 'REVERT'...message when sending test e-mail

TITLE: Microsoft SQL Server Management Studio
--
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
--
ADDITIONAL INFORMATION:
Incorrect syntax near 'REVERT'. 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.
Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
--
BUTTONS:
OK
--Are you using a database in compatibility mode? Right-click on database,
properties, Options, compatability level drop-down at top of dialog.
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> TITLE: Microsoft SQL Server Management Studio
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> ADDITIONAL INFORMATION:
> Incorrect syntax near 'REVERT'. 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.
> Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
> --
> BUTTONS:
> OK
> --
>|||What compatibility level is the database? I assume you have a @.query parm for the email sending, and
it seems that the database you access data from need to be in compat level 90.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> TITLE: Microsoft SQL Server Management Studio
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> ADDITIONAL INFORMATION:
> Incorrect syntax near 'REVERT'. 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.
> Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
> --
> BUTTONS:
> OK
> --
>|||Master is set to 9.0
Do I have to have all databases set to 9.0?
"Will Alber" wrote:
> Are you using a database in compatibility mode? Right-click on database,
> properties, Options, compatability level drop-down at top of dialog.
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> > TITLE: Microsoft SQL Server Management Studio
> > --
> >
> > An exception occurred while executing a Transact-SQL statement or batch.
> > (Microsoft.SqlServer.ConnectionInfo)
> >
> > --
> > ADDITIONAL INFORMATION:
> >
> > Incorrect syntax near 'REVERT'. 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.
> > Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> >
> > For help, click:
> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
> >
> > --
> > BUTTONS:
> >
> > OK
> > --
> >
>
>|||You'll need the database that is issuing this error to be set to that
compatibility level - note however that this is not without it's (potential)
problems - some SQL Server 2000 features are broken in 2005 compat. level,
so tread carefully!
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:FFBDA9F3-BFCA-4DFA-B4F8-93D063C33919@.microsoft.com...
> Master is set to 9.0
> Do I have to have all databases set to 9.0?
> "Will Alber" wrote:
>> Are you using a database in compatibility mode? Right-click on database,
>> properties, Options, compatability level drop-down at top of dialog.
>> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in
>> message
>> news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
>> > TITLE: Microsoft SQL Server Management Studio
>> > --
>> >
>> > An exception occurred while executing a Transact-SQL statement or
>> > batch.
>> > (Microsoft.SqlServer.ConnectionInfo)
>> >
>> > --
>> > ADDITIONAL INFORMATION:
>> >
>> > Incorrect syntax near 'REVERT'. 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.
>> > Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
>> >
>> > For help, click:
>> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
>> >
>> > --
>> > BUTTONS:
>> >
>> > OK
>> > --
>> >
>>|||I don't know what database it is. I'm simply trying to setup Database Mail
and test. Not really working with a particular database. I just assumed
that it was with the Master. I have about 6 databases on this server. -
Thanks.
"Will Alber" wrote:
> You'll need the database that is issuing this error to be set to that
> compatibility level - note however that this is not without it's (potential)
> problems - some SQL Server 2000 features are broken in 2005 compat. level,
> so tread carefully!
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:FFBDA9F3-BFCA-4DFA-B4F8-93D063C33919@.microsoft.com...
> > Master is set to 9.0
> > Do I have to have all databases set to 9.0?
> >
> > "Will Alber" wrote:
> >
> >> Are you using a database in compatibility mode? Right-click on database,
> >> properties, Options, compatability level drop-down at top of dialog.
> >>
> >> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in
> >> message
> >> news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> >> > TITLE: Microsoft SQL Server Management Studio
> >> > --
> >> >
> >> > An exception occurred while executing a Transact-SQL statement or
> >> > batch.
> >> > (Microsoft.SqlServer.ConnectionInfo)
> >> >
> >> > --
> >> > ADDITIONAL INFORMATION:
> >> >
> >> > Incorrect syntax near 'REVERT'. 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.
> >> > Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> >> >
> >> > For help, click:
> >> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476
> >> >
> >> > --
> >> > BUTTONS:
> >> >
> >> > OK
> >> > --
> >> >
> >>
> >>
> >>
>
>|||You might also try msdb, I believe this is where all the dbmail stuff lives.
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:9BC7D1DF-4D4B-4BD6-9256-E02E0E1C970D@.microsoft.com...
>I don't know what database it is. I'm simply trying to setup Database Mail
> and test. Not really working with a particular database. I just assumed
> that it was with the Master. I have about 6 databases on this server. -
> Thanks.|||... and just for the heck of it, while no-one is connected, make sure all is in 90 mode. If it
works, lower one at a time and see which one caused the problems.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OJYKqcCuHHA.4948@.TK2MSFTNGP06.phx.gbl...
> You might also try msdb, I believe this is where all the dbmail stuff lives.
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:9BC7D1DF-4D4B-4BD6-9256-E02E0E1C970D@.microsoft.com...
>>I don't know what database it is. I'm simply trying to setup Database Mail
>> and test. Not really working with a particular database. I just assumed
>> that it was with the Master. I have about 6 databases on this server. -
>> Thanks.
>|||Changing msdb to 9.0 worked.
Thanks.
Problem resolved.
"Tibor Karaszi" wrote:
> ... and just for the heck of it, while no-one is connected, make sure all is in 90 mode. If it
> works, lower one at a time and see which one caused the problems.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:OJYKqcCuHHA.4948@.TK2MSFTNGP06.phx.gbl...
> > You might also try msdb, I believe this is where all the dbmail stuff lives.
> >
> > --
> > Aaron Bertrand
> > SQL Server MVP
> > http://www.sqlblog.com/
> > http://www.aspfaq.com/5006
> >
> >
> >
> > "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> > news:9BC7D1DF-4D4B-4BD6-9256-E02E0E1C970D@.microsoft.com...
> >>I don't know what database it is. I'm simply trying to setup Database Mail
> >> and test. Not really working with a particular database. I just assumed
> >> that it was with the Master. I have about 6 databases on this server. -
> >> Thanks.
> >
> >
>|||> Changing msdb to 9.0 worked.
> Thanks.
> Problem resolved.
Since I was able to reproduce this in Katmai I filed an issue on Connect:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=284340
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006

Incorrect syntax near 'REVERT'...message when sending test e-mail

TITLE: Microsoft SQL Server Management Studio
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
ADDITIONAL INFORMATION:
Incorrect syntax near 'REVERT'. 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.
Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
For help, click:
[url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476[/url]
BUTTONS:
OK
What compatibility level is the database? I assume you have a @.query parm for the email sending, and
it seems that the database you access data from need to be in compat level 90.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> TITLE: Microsoft SQL Server Management Studio
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> ADDITIONAL INFORMATION:
> Incorrect syntax near 'REVERT'. 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.
> Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> For help, click:
> [url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .3042&EvtSrc=MSSQLServer&EvtID=325&LinkId=20476[/url]
> --
> BUTTONS:
> OK
> --
>
|||Master is set to 9.0
Do I have to have all databases set to 9.0?
"Will Alber" wrote:

> Are you using a database in compatibility mode? Right-click on database,
> properties, Options, compatability level drop-down at top of dialog.
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
>
>
|||I don't know what database it is. I'm simply trying to setup Database Mail
and test. Not really working with a particular database. I just assumed
that it was with the Master. I have about 6 databases on this server. -
Thanks.
"Will Alber" wrote:

> You'll need the database that is issuing this error to be set to that
> compatibility level - note however that this is not without it's (potential)
> problems - some SQL Server 2000 features are broken in 2005 compat. level,
> so tread carefully!
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:FFBDA9F3-BFCA-4DFA-B4F8-93D063C33919@.microsoft.com...
>
>
|||You might also try msdb, I believe this is where all the dbmail stuff lives.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:9BC7D1DF-4D4B-4BD6-9256-E02E0E1C970D@.microsoft.com...
>I don't know what database it is. I'm simply trying to setup Database Mail
> and test. Not really working with a particular database. I just assumed
> that it was with the Master. I have about 6 databases on this server. -
> Thanks.
|||... and just for the heck of it, while no-one is connected, make sure all is in 90 mode. If it
works, lower one at a time and see which one caused the problems.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OJYKqcCuHHA.4948@.TK2MSFTNGP06.phx.gbl...
> You might also try msdb, I believe this is where all the dbmail stuff lives.
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>
> "JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
> news:9BC7D1DF-4D4B-4BD6-9256-E02E0E1C970D@.microsoft.com...
>
|||Changing msdb to 9.0 worked.
Thanks.
Problem resolved.
"Tibor Karaszi" wrote:

> ... and just for the heck of it, while no-one is connected, make sure all is in 90 mode. If it
> works, lower one at a time and see which one caused the problems.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:OJYKqcCuHHA.4948@.TK2MSFTNGP06.phx.gbl...
>
|||> Changing msdb to 9.0 worked.
> Thanks.
> Problem resolved.
Since I was able to reproduce this in Katmai I filed an issue on Connect:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=284340
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006

Incorrect syntax near 'REVERT'...message when sending test e-mail

TITLE: Microsoft SQL Server Management Studio
--
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
ADDITIONAL INFORMATION:
Incorrect syntax near 'REVERT'. 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.
Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
For help, click:
http://go.microsoft.com/fwlink?Prod...25&LinkId=20476
BUTTONS:
OK
--Are you using a database in compatibility mode? Right-click on database,
properties, Options, compatability level drop-down at top of dialog.
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> TITLE: Microsoft SQL Server Management Studio
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> ADDITIONAL INFORMATION:
> Incorrect syntax near 'REVERT'. 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.
> Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...25&LinkId=20476
> --
> BUTTONS:
> OK
> --
>|||What compatibility level is the database? I assume you have a @.query parm fo
r the email sending, and
it seems that the database you access data from need to be in compat level 9
0.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"JimCinAlabama" <JimCinAlabama@.discussions.microsoft.com> wrote in message
news:60EF2EE1-2BE2-4D88-9B54-5B0BA3B58AE7@.microsoft.com...
> TITLE: Microsoft SQL Server Management Studio
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> ADDITIONAL INFORMATION:
> Incorrect syntax near 'REVERT'. You may need to set the compatibility leve
l
> of the current database to a higher value to enable this feature. See help
> for the stored procedure sp_dbcmptlevel.
> Incorrect syntax near 'REVERT'. (Microsoft SQL Server, Error: 325)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...25&LinkId=20476
> --
> BUTTONS:
> OK
> --
>

Friday, March 9, 2012

inconsistancy in execution time of SP. Need help.

Hi,
I have a stored procedure which creates a temporary table and insert into it
selected entries.
When executing the procedure, selecting few thousands entries, it takes few
MINUTES for it to finish.
When executing the same code in the query analyzer it takes a second to
finish.
I can't work as the accessing web page fails to get the data because of the
long time it takes.
Does anyone have an idea what's wrong with my procedure?
Thanks,
I.P.You're seeing sp recompiled. I suggest you take a look at this kb.
http://support.microsoft.com/kb/243586
-oj
"I.P." <lafafa@.yahoo.com> wrote in message
news:d7hce4$b86$1@.news.iucc.ac.il...
> Hi,
> I have a stored procedure which creates a temporary table and insert into
> it selected entries.
> When executing the procedure, selecting few thousands entries, it takes
> few MINUTES for it to finish.
> When executing the same code in the query analyzer it takes a second to
> finish.
> I can't work as the accessing web page fails to get the data because of
> the long time it takes.
> Does anyone have an idea what's wrong with my procedure?
> Thanks,
> I.P.
>|||Thanks.
"oj" <nospam_ojngo@.home.com> wrote in message
news:O7xa0gcZFHA.3780@.tk2msftngp13.phx.gbl...
> You're seeing sp recompiled. I suggest you take a look at this kb.
> http://support.microsoft.com/kb/243586
>
> --
> -oj
>
> "I.P." <lafafa@.yahoo.com> wrote in message
> news:d7hce4$b86$1@.news.iucc.ac.il...
>