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
 Adding a field in SQL

Author  Topic 

JonahMk2
Starting Member

21 Posts

Posted - 2006-04-18 : 11:11:16
I need to add a field to a query which i have created in SQL Server, i have done this in Access no problem and it works fine but when icopy the SQL code from Access to SQL it just falls over. This is my code in Access...

SELECT AIMPDTA_CDADDR.CDCUST, AIMPDTA_CDADDR.CDADDC, AIMPDTA_CDADDR.CDNAME, AIMPDTA_CDADDR.CDADD1, AIMPDTA_CDADDR.CDADD2, AIMPDTA_CDADDR.CDADD3, [CDCUST] & [CDADDC] AS Expr1
FROM AIMPDTA_CDADDR LEFT JOIN AIMPDTA_ASAREA ON AIMPDTA_CDADDR.CDNAME = AIMPDTA_ASAREA.ASNAME
WHERE (((AIMPDTA_CDADDR.CDADDC)<>" "));

Any suggestions would be much appreciated.

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-18 : 11:43:54
[CDCUST] + [CDADDC] as Expr1
or
convert(varchar(100),[CDCUST]) + convert(varchar(100),[CDADDC]) as Expr1

depending on the datatype.

==========================================
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.
Go to Top of Page

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-04-18 : 16:00:26
If you have the command in SQL Code already, why not just modify the command and hand type the extra field you are trying to bring back?

Access and TSQL code are not completely compatible. Besides the "+" above, I think you'll also probably need to convert the WHERE clause to <> ' ' (single quotes instead of double.)
Go to Top of Page
   

- Advertisement -