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 |
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2009-03-20 : 07:22:23
|
Dear All,I am using sql server 2005.My requirement is given date and month. Make date and compare it from today and find the diffence if difference is below 7 show the perticular detail.My problem is I have a table(Event_attribute) from where I come to know which field of main table(Customer_attributes) to search on Which is asEvent_attribute Eventid Dd field Mm field1 Ca_dd_dob Ca_mm_dob2 Ca_dd_doa Ca_mm_doaThis ca_dd_dob , ca_mm_dob , ca_dd_doa , ca_mm_doa are field of another table customer_attributesDoctor Ca_dd_dob Ca_mm_dob Ca_dd_doa Ca_dd_doaD00045 20 2 15 5Now when I run the query SELECT (SELECT DD_field FROM CMS_EVENT_ATT_REL WHERE EAR_EVENTID = 1) FROM CMS_CUSTOMER_ATTRIBUTESIt returns me ca_dd_dob rather then returning 20. I tried with dynamic query it show me datatype mismatch as it also return ca_dd_dobPlease suggest |
|
|
matty
Posting Yak Master
161 Posts |
Posted - 2009-03-20 : 07:35:16
|
| Use Dynamic SQL |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-20 : 08:33:21
|
| www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|