Columnname In Sql

Oct 2, 2007

 

how to select all column names from sql whose columnvalue is '1' for a specific user


 

 

View 4 Replies


ADVERTISEMENT

Dynamic ColumnName

Jun 3, 2005

Howdy all,I'm trying to create a sproc that has the column name and search text as input parameters with dynamic SQL...  what I have is:-- Create a variable @SQLStatementDECLARE @SQLStatement varchar(255)SELECT @SQLStatement = 'SELECT * FROM myTable WHERE (''' + @ColumnName + ''' = ''' + @SearchText + ''')'-- Execute the SQL statementEXEC(@SQLStatement)The procedure works (at least in Query Analyzer, once I declare/set @columnname and @searchtext) in that I don't get any errors.  But it returns a blank table with "0 rows affected".  However, if I hardcode the variables, it returns the proper data.  What's wrong with my select statement??  Thanks!!JP

View 2 Replies View Related

&<Tablename&> . . &<ColumnName&>

Apr 30, 2004

Hi,
What is the difference between
<Tablename> . . <ColumnName> and <Tablename> . <ColumnName>
this syntax we are using in Storedprocedures.
In SQL 2000, <Tablename> . . <ColumnName> is not working

Eg:
Tablename =a
Column Name = b
Difference between a..b and a.b

Can anyone let me know.

TIA,
Ravi

View 2 Replies View Related

How To Select ColumnName From A Table?

Mar 20, 2008

Hi
I know the answere is out there, but i cant find it.I would like to have a dropdownlist in my webpage (asp.net/vb.net) to have values dynamicly collected from my database.The values should be the ColumnName of all columns i have in a speciall table.
 How can i make the dropdownlist to have the ColumnName from every column i the table?My sqlcommand looks like this down under but i would like me.ColumnName to be a ColumnName value.New SqlCommand("Select * from tblmytable where " & Me.ColumnName & " = 'true'", myConnection) Greatful for help!/ Mitmit 

View 5 Replies View Related

WHERE ColumnName = 'this' AND AnotherColumnName IS NOT NULL

Nov 9, 2006

Using SQL Query Analyzer how do I do something like:WHERE columnName = 'this' AND anotherColumnName IS NOT NULLI.E.SELECT *FROM CES_DATAWHERE DIV = 'MW'AND Not IsNull ROORDER BY RO

View 1 Replies View Related

Stored Procedure Dynamically Determine Columnname

Dec 3, 2006

I want to dynamically determine which column I select data from. The table I want to select from looks like this:tblSexualitySexualityID int PKEN nvarchar(20)NL nvarchar(20)DE nvarchar(20)Based on the value of variable @LanguageColumnName I want to select the value from either column "EN", "NL" or "DE"In the sample below the value of @LanguageColumnName is "NL".Unfortunately the value of sexualityname is ALWAYS: "tblSexuality.NL" and not the value from that specific column...how can I alter my procedure so that it does the select the value from that column?ALTER PROCEDURE [dbo].[spFindUsers]@LanguageColumnName nvarchar(3),@startRowIndex int,@maximumRows intASBEGINSET NOCOUNT ON;
declare @tblSexualityName nvarchar(40)set @tblSexualityName='tblSexuality.' + @LanguageColumnName SELECT UserName,UserCode,ThumbNailPicture,BirthDate,ShowAgeOnly,IsMale,NearestBigCity,DistanceToNearestBigCity,Description,IsDonator,IsVIP,SexualityName FROM(SELECT ROW_NUMBER() OVER (ORDER BY UserCode) as RowNum,tblUserData.UserName,UserCode,IsDonator,IsVIP,Description,BirthDate,IsMale,ShowAgeOnly,tblCountries.CountryPicture,@tblSexualityName as sexualityname,tblCountries.CountryName,ThumbNailPicture,LastActivityDate,UserRanking,NearestBigCity,DistanceToNearestBigCity FROM aspnet_Users INNER JOIN tblUserData ON aspnet_Users.UserId = tblUserData.UserID INNER JOIN tblCountries ON tblUserData.Country=tblCountries.CountryID INNER JOIN tblSexuality ON tblUserData.Sexuality=tblSexuality.SexualityID) as MemberInfoWHERE RowNum > @startRowIndex AND RowNum <= (@startRowIndex + @maximumRows)END
 

View 1 Replies View Related

SELECT Columns By Column-index NOT By Columnname!

Nov 20, 2005

Hello all,

how can I select one or more columns from a table by column-index and NOT by columnname?

e.g.:

SELECT tbl1.[1], tbl1.[2], tbl1.[3] FROM Orders AS tbl1

and NOT like this:

SELECT tbl1.OrderNo, tbl1.ProductNo, tbl1.Price FROM Orders AS tbl1

Is that possible in MS-SQL 2000?

Thanks a lot in advance

kind regards

Otto

View 11 Replies View Related

SSIS - Failure Inserting Into The Read-only Column ColumnName

May 10, 2007

Hi folks, I have a little challenge for you, I hope :)

The short story is as follows: I have multiple rather well normalized tables, and a view which connect them all togheter. In one of the tables I have an xml column, which I in the view to varchar(4000), since SSIS doesn't like xml all that much. To make the view updateable I have an instead of trigger placed on it, which works quite perfectly from T-SQL. SSIS however, claims that I cannot insert to a read-only column. Does anyone have the slightest idea how I can get around this?

The only solution I can think of is having two columns for the XML data, one as varchar and the other as varchar, then having a trigger updating the xml column when the varchar is updated, but that would require recursive triggers, which I am not too happy with.

Cheers

View 11 Replies View Related

How To Save Filename As Columnname In Flat File Dest Config

Oct 20, 2006

I have created a SSIS pkg (datasource and flat file destination)

I need to have the flatfile renamed after each exec to a column name that exists in the table I am running the pkg against.

Where does the code get put to make this change after the file has been created?

Basically if I could run T-SQL after the file creation, I could make it work.



thx..

View 1 Replies View Related

Count(*) Vs Count(columnname)

Aug 28, 2007

 Is there a difference in performance when using count(*) or count(columnname)?

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved