April 3, 2007 at 2:17 pm
Hi,
i need help on this.i have a query as below
select *
from [Header$]
WHERE [Project #] is not null
I WANT TO RAISE ERROR WHEN [Project #] is not null
Any help is appreciated
April 3, 2007 at 2:40 pm
IF (SELECT COUNT(*) FROM [Header$] WHERE [Project#] IS NOT NULL) > 0
THEN
RAISERROR(.......)
April 3, 2007 at 5:07 pm
i need to know what is the syntax for RAISE ERROR
April 3, 2007 at 6:03 pm
The syntax is in BOL under the keyword RAISERROR. Note that it's one word, and that it's technically missing an "e", but that's where it's located.
April 3, 2007 at 6:12 pm
i have found it but i cant still make it work.i would appreciate if you can help me in this case
April 3, 2007 at 6:40 pm
Show us the code you have so far, and we can figure out what's wrong with it.
April 3, 2007 at 6:44 pm
IF
(SELECT COUNT(*) FROM [Header$] WHERE [Project#] IS NOT NULL) > 0
THEN
RAISERROR
('Hi there, I ' ' an error',1,1)
end
April 3, 2007 at 7:38 pm
SQL Server doesn't use IF/THEN syntax, it's just an IF (using begin/end for blocks of statements). Your "end" needs a matching "begin" as well. What is the space surrounded by single quotes in the middle of your error string supposed to do? It just breaks up the string into two pieces, thus causing a syntax error.
April 3, 2007 at 7:46 pm
SELECT
*
FROM
[Header$]
WHERE
[Project #] IS NOT NULL
IF
@@ERROR = 0
RAISERROR
('Please enter.',1,1)
IS THAT FINE YOU THINK OR IT STILL HAS PROBLEM
April 3, 2007 at 7:54 pm
Now I'm totally lost. Why did you add the @@ERROR, and why does your message now say "Please enter", and why do I feel like this is homework?
Based on my reading of your original question, using your code prior to this latest post and fixing the issues I noted, will do what you want. I don't know what you're trying to accomplish with this latest bit of code.
April 3, 2007 at 8:05 pm
Best,
did you read answers here:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=355132 ?
Did you get it?
Can you repeat what did you get?
_____________
Code for TallyGenerator
April 3, 2007 at 8:09 pm
LET ME TELL YOU THE EXACT SITUATION
iam using SSIS.I have created a package which gets data from excel and import into sql server database.
now what is happening is i use the following sql command to get the data at the source level from excel
select *
from [Header$]
now iam trying to USE RAISERROR in case the column [Project #] is not null in the sql command.The column [Project #] is one of the column in my excel sheet [Table-Header$]
April 3, 2007 at 8:50 pm
Why do you want to raise an error if there is a value in the column? If you don't want that value, just don't bring it across. What are the exact conditions that would need to be met for your transfer to be considered successful?
April 3, 2007 at 8:51 pm
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply