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 |
|
jpockets
Starting Member
45 Posts |
Posted - 2007-06-07 : 12:26:30
|
| Hi everyone I'm trying to get 4 columns from my table to be on column, not sure how to go about it. The column names are X_POLICY_NO,X_POLICY_EFCTV_DT,PRODUCT_ABBR,X_ASCO_CDI would like to take those 4 columns in the select statement and make them on, I did in access but I tried Select (X_POLICY_NO, X_POLICY_EFCTV_DT, PRODUCT_ABBR, X_ASCO_CD) as CONCAT but i get an error that says :Incorrect syntax, thanks for the help its greatly appreciated |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-07 : 12:29:14
|
| X_POLICY_NO + X_POLICY_EFCTV_DT + PRODUCT_ABBR + X_ASCO_CD as CONCAT you will probably need to cast datatypesconvert(varchar(20),X_POLICY_NO) + convert(varchar(8),X_POLICY_EFCTV_DT,112) + PRODUCT_ABBR + X_ASCO_CD as CONCAT ==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jpockets
Starting Member
45 Posts |
Posted - 2007-06-07 : 15:27:45
|
| Thank-you got it working just had a litle problem like you said converting it!!!! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-08 : 09:52:43
|
| Also make sure you handle NULL valuesMadhivananFailing to plan is Planning to fail |
 |
|
|
mageshks
Yak Posting Veteran
59 Posts |
Posted - 2007-06-08 : 23:13:36
|
| You can use CAST too |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-09 : 00:35:19
|
quote: Originally posted by mageshks You can use CAST too
But again you need to handle NULLMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|