Tuesday, March 20, 2012
Problem executing stored procedure to update all rows of a table
I got a stored procedure which interacts with the pubs database. The
following is the code for the stored procedure:
CREATE PROCEDURE usp_UpdatedPrices_para
@.Type char(12)= '%',
@.Percent Money
AS
UPDATE titles
SET Price = Price * (1 + @.percent/100)
WHERE Type = @.Type
Now, if I execute the above stored procedure(from QA) in the following manne
r:
exec usp_UpdatedPrices_para 'Business' , 1
all four rows of the price field of titles table corresponding to the
'Business' type gets updated.
Now I need to execute the stored procedure so that all the rows get the
updates for all the various types. Since I have a default value for the type
as '%', I am
executing the stored procedure as
exec usp_UpdatedPrices_para , 1
to which I am getting a syntax error as the following:
Line 1: Incorrect syntax near ','
If anybody could suggest me something about the error, it would be helpful.
Thanks.Hello, Jack
You can call the procedure like this:
EXEC usp_UpdatedPrices_para DEFAULT, 1
or:
EXEC usp_UpdatedPrices_para @.Percent=1
However, this will not get you the expected result, because your
condition is "Type='%'" (not "Type LIKE '%'"). I suggest that you omit
the default for the @.Type parameter (leave it to be NULL) and use a
condition like this:
WHERE Type=@.Type OR @.Type IS NULL
Razvan
Wednesday, March 7, 2012
Problem Creating Full-Text Catalog on Pubs
I have just installed SQL Server 2005 Developer Edition and attached the Pubs database that is enabled for full-text searching and I have run full-text searches on it using Sql Server 2005 Express. When i tried to search, I was informed that the catalog was not in a stable condition. I ran this script
Drop FullText Catalog PubsCatalog
I got this message:
Warning: The fulltext catalog 'PubsCatalog' is being dropped and is currently set as default.
When I try to create a new PubsCatalog, I get:
Msg 7689, Level 16, State 1, Line 1
Execution of a full-text operation failed. 'The dependency service does not exist or has been marked for deletion.'
I have tried other catalog names but the same result.
This was easy to do with the same db in Sql Server 2005 Express. What is wrong and how do I fix it?
The problem seems to be related to Vista. Sql Server 2005 SP2 fixed it.