Hello:
Is it possible to useCASE expression inAND condition? i.e.
-------------
CREATE PROC spBlah
(
@.id INT,
@.val INT
)
AS
SELECT *
FROM aTable
WHERE tableID = @.id
AND
(
CASE @.val WHEN 1 THEN otherCol = someValue END
CASE @.val WHEN 2 THEN otherCol != someOtherVlaue END
)
--------------AND is a Boolean Operator and is also a JOIN condition operator used by databases like SQL Server for extra JOIN search conditions. I don't think it can be used with a CASE statement. Try the link below for CASE statement code. Hope this helps.
http://www.craigsmullins.com/ssu_0899.htm|||For your case, you might try to build the query dynamically and store the query into a SQL variable. Then use the exec method to execute the query. I don't think you can do the way you are heading. Build only the variable part and then append to the fixed part. Hope I am not confusing you...
declare @.tmp varchar(300)
if(@.val = 1)
set @.tmp = 'otherCol = someValue'
else
set @.tmp = 'otherCol != someOtherVlaue'
set @.tmp = 'SELECT * FROM aTable WHERE tableID = @.id AND ' + @.tmp
exec(@.tmp)
Thanks
Showing posts with label proc. Show all posts
Showing posts with label proc. Show all posts
Saturday, February 25, 2012
Can I use a DataSet with 2 Tables in Reporting Services
I have created a DataSet with Table[0] and Table[1] in a stored proc. When I
create a new dataset using the stroed proc, I can only see Table[0]. Is it
possible to create a report using a DataSet with 2 tables such as this?
Thanks...Greyhound,
This is not possible. You have two choices;
1) Create two datasets in your report and split your stored proc up.
2) Union the results for each table into a single table and add a filter
field to filter the results in the report.
AK Code Rat
"Greyhound" wrote:
> I have created a DataSet with Table[0] and Table[1] in a stored proc. When I
> create a new dataset using the stroed proc, I can only see Table[0]. Is it
> possible to create a report using a DataSet with 2 tables such as this?
> Thanks...
create a new dataset using the stroed proc, I can only see Table[0]. Is it
possible to create a report using a DataSet with 2 tables such as this?
Thanks...Greyhound,
This is not possible. You have two choices;
1) Create two datasets in your report and split your stored proc up.
2) Union the results for each table into a single table and add a filter
field to filter the results in the report.
AK Code Rat
"Greyhound" wrote:
> I have created a DataSet with Table[0] and Table[1] in a stored proc. When I
> create a new dataset using the stroed proc, I can only see Table[0]. Is it
> possible to create a report using a DataSet with 2 tables such as this?
> Thanks...
Sunday, February 12, 2012
Can I pass ResultSet as parameter of Stored Proc directly ?
Hi, All
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.
http://www.sommarskog.se/share_data.html
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.
http://www.sommarskog.se/share_data.html
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Can I pass ResultSet as parameter of Stored Proc directly ?
Hi, All
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.http://www.sommarskog.se/share_data.html
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.http://www.sommarskog.se/share_data.html
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Can I pass ResultSet as parameter of Stored Proc directly ?
Hi, All
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.http://www.sommarskog.se/share_data.html
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Is it possible for me that I pass a resultset as parameter of Stored Proc
directly instead of putting it to a table before calling a stored procedure
which manipulate data of the table?
Thanks a lot in advance for your answer.http://www.sommarskog.se/share_data.html
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:1FBF91FA-172B-41AC-8834-0C7AAE52310D@.microsoft.com...
> Hi, All
> Is it possible for me that I pass a resultset as parameter of Stored Proc
> directly instead of putting it to a table before calling a stored
procedure
> which manipulate data of the table?
> Thanks a lot in advance for your answer.
Subscribe to:
Posts (Atom)