Click here to Skip to main content
15,892,161 members
Home / Discussions / Database
   

Database

 
GeneralRe: Searching tables Pin
mark_me23-Jul-09 7:27
mark_me23-Jul-09 7:27 
AnswerRe: database design help Pin
Mycroft Holmes23-Jul-09 1:02
professionalMycroft Holmes23-Jul-09 1:02 
GeneralRe: database design help Pin
mark_me23-Jul-09 7:26
mark_me23-Jul-09 7:26 
QuestionQuerying Versioned Data Pin
JSinJax22-Jul-09 6:34
JSinJax22-Jul-09 6:34 
AnswerRe: Querying Versioned Data Pin
David Mujica22-Jul-09 8:00
David Mujica22-Jul-09 8:00 
QuestionTypical Requirement Pin
Satish - Developer22-Jul-09 1:24
Satish - Developer22-Jul-09 1:24 
AnswerRe: Typical Requirement Pin
DoctorMick22-Jul-09 6:29
DoctorMick22-Jul-09 6:29 
AnswerRe: Typical Requirement Pin
Blue_Boy22-Jul-09 9:36
Blue_Boy22-Jul-09 9:36 
Hi,I hope i understood you good enought. Here is TSQL solution which I hope will works for you.

select * from mytable<br />
<br />
declare @zip as int<br />
set @zip = 123<br />
declare @white as varchar(100)<br />
set @white =(select white from mytable where zip=@zip)<br />
<br />
declare @black as varchar(100)<br />
set @black =(select black from mytable where zip=@zip)<br />
<br />
declare @green as varchar(100)<br />
set @green =(select green from mytable where zip=@zip)<br />
<br />
create table #temptable (valstr varchar(100),colname varchar(100))<br />
<br />
insert into #temptable values (@white,'white')<br />
insert into #temptable values (@black,'black')<br />
insert into #temptable values (@green,'green')<br />
<br />
declare @colname as varchar(100) <br />
set @colname=( select top 1 colname from #temptable order by valstr desc )<br />
drop table #temptable<br />
<br />
declare @selectquery as nvarchar(max)<br />
set @selectquery ='select '+@colname+' from mytable where zip='+cast(@zip as varchar(10))<br />
exec(@selectquery)



I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.


QuestionHow to get the next 1,000,000 records Pin
dabuskol21-Jul-09 20:18
dabuskol21-Jul-09 20:18 
AnswerRe: How to get the next 1,000,000 records Pin
Satish - Developer22-Jul-09 1:46
Satish - Developer22-Jul-09 1:46 
GeneralRe: How to get the next 1,000,000 records Pin
zahedonline22-Jul-09 21:34
zahedonline22-Jul-09 21:34 
GeneralRe: How to get the next 1,000,000 records Pin
Mycroft Holmes23-Jul-09 1:06
professionalMycroft Holmes23-Jul-09 1:06 
AnswerRe: How to get the next 1,000,000 records Pin
Mycroft Holmes23-Jul-09 1:09
professionalMycroft Holmes23-Jul-09 1:09 
QuestionHow to add trigger function into PostgreSQL 8.0? Pin
valeranavin21-Jul-09 20:17
valeranavin21-Jul-09 20:17 
QuestionMSSQL: How to check if selected string has specific letters on specific places??? Please help... Pin
Magnat7421-Jul-09 10:19
Magnat7421-Jul-09 10:19 
AnswerRe: MSSQL: How to check if selected string has specific letters on specific places??? Please help... Pin
David Mujica21-Jul-09 10:43
David Mujica21-Jul-09 10:43 
GeneralRe: MSSQL: How to check if selected string has specific letters on specific places??? Please help... Pin
Magnat7421-Jul-09 10:49
Magnat7421-Jul-09 10:49 
AnswerRe: MSSQL: How to check if selected string has specific letters on specific places??? Please help... Pin
WoutL21-Jul-09 20:42
WoutL21-Jul-09 20:42 
Generalcool use of "like" Pin
David Mujica22-Jul-09 10:17
David Mujica22-Jul-09 10:17 
GeneralRe: MSSQL: How to check if selected string has specific letters on specific places??? Please help... Pin
Blue_Boy22-Jul-09 11:33
Blue_Boy22-Jul-09 11:33 
Questioncopying the whole table from one server to another server [modified] Pin
venu65621-Jul-09 6:13
venu65621-Jul-09 6:13 
AnswerRe: copuing the whole table from one server to another server Pin
DoctorMick21-Jul-09 6:24
DoctorMick21-Jul-09 6:24 
GeneralRe: copying the whole table from one server to another server Pin
venu65621-Jul-09 6:28
venu65621-Jul-09 6:28 
GeneralRe: copying the whole table from one server to another server Pin
Robin_Roy21-Jul-09 17:56
Robin_Roy21-Jul-09 17:56 
GeneralRe: copying the whole table from one server to another server Pin
venu65621-Jul-09 18:26
venu65621-Jul-09 18:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.