Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.
-
Dean Savovic #1
Re: Conditionally show columns in SQL
Almost positive that this is impossible without using dynamic sql!
--
Dean Savovic
[url]www.teched.hr[/url]
"Pierre Dippenaar" <pierre@sentinal.co.za> wrote in message
news:d1f00c2a.0307010018.46c481a8@posting.google.c om...> I would like to show a column in a SQL statement only if a certain
> condition is true (all within a stored procedure - without using
> Dynamic SQL):
>
> Create Procedure spAuthors
> @ShowFirstName smallint
> As
>
> SELECT au_lname, au_fname (Only Show Firstname if @ShowFirstName = 1)
> FROM Authors
>
> Is this possible without using Dynamic SQL and the EXEC statement? I
> tried using the CASE statement but this still dislays a column for
> FirstName even though the values are not displayed.
Dean Savovic Guest
-
Does MS Access have a Show Columns SQL command
I have recently discovered how to Alter Add and Drop columns from MS Access. This is going to help me a lot with updating multiple databases when I... -
DropDownList show the name of columns of dataGrid
Hello, I make a dataGrid and i like to show the name of the columns of the dataGrid in a DropDownList. For example, if my dataGrid have three... -
Show/Hide Textbox Conditionally -- Even if Postback Occurs
I have a datagrid control that contains several columns of data (all bound columns) and a TextBox in the last column (in an ItemTemplate). If the... -
SQL plugin and Show columns query
Hi, I would like to know how can I execute and see the result of "Show Columns From table.name from db.name" using SQL plugin with MySQL... -
can't get data to show with bound columns
I'm trying to create a DataGrid filled with values from a DataSet and I want the user to be able to show and hide whichever columns they choose. I... -
Jacco Schalkwijk #2
Re: Conditionally show columns in SQL
Create Procedure spAuthors
@ShowFirstName smallint
AS
SET NOCOUNT ON
IF @ShowFirstName = 1
SELECT au_lname, au_fname
FROM Authors
ELSE
SELECT au_lname
FROM Authors
I think you shouldn't go too far with making the output of your stored
procedures dynamic, it will only confuse in the end. If your rowssets are
reasonably small the performance improvement of not sending the extra data
over the network is neglegible and it is far easier handled in the client.
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Pierre Dippenaar" <pierre@sentinal.co.za> wrote in message
news:d1f00c2a.0307010018.46c481a8@posting.google.c om...> I would like to show a column in a SQL statement only if a certain
> condition is true (all within a stored procedure - without using
> Dynamic SQL):
>
> Create Procedure spAuthors
> @ShowFirstName smallint
> As
>
> SELECT au_lname, au_fname (Only Show Firstname if @ShowFirstName = 1)
> FROM Authors
>
> Is this possible without using Dynamic SQL and the EXEC statement? I
> tried using the CASE statement but this still dislays a column for
> FirstName even though the values are not displayed.
Jacco Schalkwijk Guest



Reply With Quote

