Possible Duplicate:
trim left characters in sql server?
I have a query below that grabs customer information from our database to send coupons. In regards to the ZIP code, we only want the first 5 digits of the field… How can I return ONLY the first 5? My code is below:
SELECT Invoice_Tb.Customer_First_Name AS firstname, Invoice_Tb.Customer_Last_Name AS lastname, Invoice_Tb.Customer_Address AS add1, Invoice_Tb.City,
Invoice_Tb.Customer_State AS State, Invoice_Tb.ZIP_Code AS ZIP, Invoice_Tb.Customer_Email_Address AS [Email Address],
Invoice_Tb.Vehicle_Mileage AS [Vehicle Mileage], Invoice_Tb.Invoice_Date AS [Date Of Service], Invoice_Tb.Store_Number, @startdate AS Start_Date, @enddate AS End_Date
FROM Invoice_Detail_Tb INNER JOIN
Invoice_Tb ON Invoice_Detail_Tb.Invoice_Number = Invoice_Tb.Invoice_Number AND Invoice_Detail_Tb.Invoice_Date = Invoice_Tb.Invoice_Date
WHERE (Invoice_Detail_Tb.Store_Category_Code = 'FS') AND (Invoice_Tb.Invoice_Date BETWEEN CONVERT(DATETIME, @startdate, 102) AND CONVERT(Datetime,
@enddate, 102)) AND (Invoice_Tb.Reminder_Mail_Flag = 'Y')
Try
e.g.
Table:
Result: