Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Column Name on left?

Author  Topic 

teddawson
Starting Member

3 Posts

Posted - 2010-10-01 : 10:39:47
I need to write a query like this:

Select *
from tableName
where someSessionVariable like %ColumnName%


Is there a way to get this done, having the Column Name on the right, or am I barking up the wrong tree?

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-10-01 : 10:49:23
Huh? I don't quite get what you are asking for.

Can you provide a use case example?

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

teddawson
Starting Member

3 Posts

Posted - 2010-10-01 : 10:54:45
I didn't ask my question correctly; the query should have been:
Select *
from tableName
where someSessionVariable like %ColumnValue%
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-10-01 : 11:00:26
Ok -- that's not what I meant because I still don't know what you really want.

Can you provide a simple table format -- with some data and show us how you need to query the table.

For example

CREATE TABLE #myTable(
[foo1] INT PRIMARY KEY
, [foo2] VARCHAR(255)
)

INSERT #myTable
SELECT 1, 'a'
UNION SELECT 2, 'b'
...
...

-- DESCRIPTION OF WHAT YOU NEED BASED ON THAT DATA HERE.....

From what you've written I don't know if you want to search for a value that is in a column of if you are really wanting to do something else (I suspect something else but I can't tell what)

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2010-10-01 : 11:01:08
Can you provide what the data currently looks like and what the expected results would be? And DDL if possible.

Terry

-- You can't be late until you show up.

--Edit - Sorry, we must've hit reply at roughly the same time.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-10-01 : 11:10:56
quote:
Originally posted by tosscrosby

Can you provide what the data currently looks like and what the expected results would be? And DDL if possible.

Terry

-- You can't be late until you show up.

--Edit - Sorry, we must've hit reply at roughly the same time.


There should be a question picture like the picture. Except with a big question mark rather than a guy with a gun.

Maybe [ H U H ? ]

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

teddawson
Starting Member

3 Posts

Posted - 2010-10-02 : 07:55:57
Hey guys, thanks for looking... I found my problem. Yes, I was trying to compare apples to oranges and I wasn't getting the results I wanted. Once I fixed my data to where I could compare apples to apples, everything worked as I expected!

Thanks for looking! You guys are the best!


Ted
Go to Top of Page
   

- Advertisement -