Solved

Select and convert to string

Posted on 2013-11-12
2
353 Views
Last Modified: 2013-11-12
I am using a dreamweaver extension to export data to excel but it has a bug and gives an error upon a large number.
Workaround is to select the fields for the recordset and convert them into 'string' so that the error is avoided, they said I should add "number" (quotes) before and after the number.

How can I do this ?  this is my select statement:

--

SELECT a.UserId, a.UserType, a.FirmId, a.EmployerId, a.LastNm, a.FirstNm, a.DobD, a.SSN, a.Email, a.Nationality, a.NiStatus, a.ExpiresOnD, a.Docstatusstat, a.NIVMaxStatus, a.I94DateD, a.I94, a.I797Date, a.I797, a.EadDate, a.Ead, a.ApDate, a.ApNum, a.Iap66Date, a.Iap66, a.GcDate, a.GC, a.I20Date, a.I20, a.PpExpireOnD, a.PpNum, a.PobCountry, b.MaidenNm as Employer, d.MailStr + ' ' + d.MaidenNm as Attorney, a.PobCountry, a.archivedcont, a.contactstatus, a.Docstatusstat, e.Docstatdesc,a.Dswg, a.VisaExp, a.VisaType, a.VisaStatus
FROM users a Left join users as b on a.employerid = b.userid Inner join attscont as c on a.userid = c.userid Inner join users as d on c.attyid = d.userid left join Documentstatus as e on e.documentstatus = a.Docstatusstat
WHERE a.usertype = 'contact' and a.firmid = MMColParam AND d.userid = MMColParam2 AND a.Archivedcont LIKE 'MMColParam3' and a.Contactstatus LIKE 'MMColParam4' AND ISNULL (a.FirstNm,'') LIKE 'MMColParam5%' and ISNULL (a.LastNm,'') LIKE 'MMColParam6%' and ISNULL (a.SSN,'') LIKE 'MMColParam7%' and ISNULL (a.email,'') LIKE 'MMColParam8%' and ISNULL (a.Nationality,'') LIKE 'MMColParam9%' AND ISNULL (a.Nistatus,'') LIKE 'MMColParam10%'
ORDER BY MMColParam500

--
0
Comment
Question by:amucinobluedot
2 Comments
 
LVL 5

Accepted Solution

by:
dannygonzalez09 earned 500 total points
ID: 39642056
you can do this to convert a numeric or integer column to string

SELECT '"' + CONVERT(VARCHAR(10),IntegerColumnName) + '"'

what i'm doing here is inserting " (double quotes with in single quotes) and concatenating it with integer column convert to a string

change the integerColumnname with your numeric or integer column and you can also change the length to what ever you want ex: VARCHAR(10) to VARCHAR(50)
0
 

Author Closing Comment

by:amucinobluedot
ID: 39642102
:)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now