Showing posts with label everybody. Show all posts
Showing posts with label everybody. Show all posts

Monday, March 19, 2012

Is there WHERE for columns

Hi everybody,
Is there a way to filter columns at runtime based on their name?

I create SELECT statement which includes all columns, then, if I get some parameter I leave some columns out and don't select data from them.

Is it possible?

I'm working with MS SQL 2000.You can't omit columns. The closest thing you can do is use CASE expressions to hide the data you don't want to show, such as:

SELECT Col1, Col2, CASE WHEN Col1 = 'someValue' THEN Col3 ELSE NULL END AS Col3
FROM YourTable|||Is this possible:

SELECT Col1, Col2, CASE WHEN SomethingOutsideThisSelectCommand = 'someValue' THEN Col3 ELSE NULL END AS Col3
FROM YourTable|||As long as it's a valid SQL expression, it shouldn't be a problem.

Monday, March 12, 2012

Is there sp_helptext for tables

Hello Everybody, Please help me out:

Is there a system stored procedure for retrieving the sql statement that created a table.

I know i can use sp_helptext for views etc; i want the equivalent for tables.

sp_columns is not adequate either.

please help! thanks in advance;)sp_help will return all the columns of a table.|||sp_help will return all the columns of a table.
Hi Blindman,

I ran exec sp_help tblcustomers and i got:

Name: tblcustomers
Owner: dbo
Type: user table
Created_datetime: 4/18/2007 2:26:12 PM

Am i missing something??