473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CASE statement in Store Procedures

I need Syntax information about CASE Statement.

CREATE PROCEDURE test
@flag varchar (20),
@FieldValues Varchar( 500 ),
TableName Varchar( 100 ),
FieldNames Varchar( 500 )
AS
BEGIN
SET NOCOUNT ON ;

CASE
WHEN @flag = 'emp' THEN
Tablename = 'dbo.emp'
FieldNames = 'code,name,addr'
END CASE;

END


Above is my code when i compile i m getting following error.]

Error: Msg 156, Level 15, State 1, Procedure test, Line 13
Incorrect syntax near the keyword 'CASE'.

Please help me in solving it.
Mar 2 '07 #1
2 7924
dorinbogdan
839 Expert 512MB
Try this way:
Expand|Select|Wrap|Line Numbers
  1. CASE
  2. WHEN @flag = 'emp' THEN
  3. BEGIN
  4. Tablename = 'dbo.emp'
  5. FieldNames = 'code,name,addr'
  6. END
  7. END;
Mar 2 '07 #2
I need Syntax information about CASE Statement.

CREATE PROCEDURE test
@flag varchar (20),
@FieldValues Varchar( 500 ),
TableName Varchar( 100 ),
FieldNames Varchar( 500 )
AS
BEGIN
SET NOCOUNT ON ;

CASE
WHEN @flag = 'emp' THEN
Tablename = 'dbo.emp'
FieldNames = 'code,name,addr'
END CASE;

END


Above is my code when i compile i m getting following error.]

Error: Msg 156, Level 15, State 1, Procedure test, Line 13
Incorrect syntax near the keyword 'CASE'.

Please help me in solving it.
Why can't you do a simple if statements insted, that is effectivly what you are doing
Mar 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: A.M. de Jong | last post by:
How does MicroSoft store the stored procedures in seperate files. What tools are used. Cause that's what I like to do too. Arno de Jong, The Netherlands. (SCPTFXR does not have the option to...
12
by: Sanjay | last post by:
hi, We are currently porting our project from VB6 to VB .NET. Earlier we used to make scale transformations on objects like pictureBox , forms etc.Now Such transformations are made on the...
2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
0
by: Uma | last post by:
Hi .. I am writing a simple stored procedure like this .. CREATE PROCEDURE DB2ADMIN.Proc1 (P1 INT,out P2 CHAR(20) ) RESULT SETS 1 LANGUAGE SQL...
1
by: esmith2112 | last post by:
We all of a sudden find ourselves in dire straits, because we have one of those mysteries where everything used to work, and apparently, all of a sudden everything went to pot just in time for a...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
4
by: deko | last post by:
When I loop through this function, it works fine until it hits End Function - then it jumps to End Select. Very strange... This behavior occurs when Case = 255. Any ideas why this is happening? ...
2
by: Marc | last post by:
Hi: Does anyone know if IBM (or any other IT Software company) offers store procedure classes anywhere in the country? Thanks Marc
2
by: sweetpotatop | last post by:
Hi, I believe my SQL server was configured as Case sensitivity. I have a number of stored procedures which were moved from a non-Case sensitivity SQL server. Because of the Case sensitivity, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.