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.
| Author |
Topic |
|
velnias2010
Posting Yak Master
125 Posts |
Posted - 2010-11-24 : 11:13:31
|
| SELECT form_field_value AS RefNumber, (SELECT form_field_value FROM form_data_tbl WHERE (form_id = 888) AND (form_field_name = 'Surname')) AS SurnameFROM form_data_tbl AS xWHERE (form_id = 888) AND (form_field_name = 'refNumber')Hey See Above,I want to basically pull surname and firstname from this db but its kinda awkward way data is stored.Can u see above how I can get around the error ? |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2010-11-24 : 11:16:59
|
| check the sub query.is it returning one record or multiple records.you have to refine the sub query so that it returns only one record. |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-11-24 : 11:20:26
|
| Could change it to(SELECT top 1 form_field_valueFROM form_data_tblWHERE (form_id = 888) AND (form_field_name = 'Surname')) AS SurnameBut that might be the wrong valueWhy not start from SELECT x.form_field_value AS RefNumber,x2.form_field_value as SurnameFROM form_data_tbl AS x join form_data_tbl x2 on x.form_id = x2.form_id and x2.form_field_name = 'Surname'WHERE x.form_id = 888 AND x.form_field_name = 'refNumber'==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-11-24 : 11:21:07
|
| can you show how data is stored in your table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|