Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create empty column in results
Message
 
 
To
13/06/2008 11:05:35
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01323801
Message ID:
01323852
Views:
21
Use quotename function to add quotes and I guess one of your fields is not a character type, so you would need to CONVERT it to string first.

Also try to use CHAR() and not VARCHAR()


>>Also perhaps there is a SQL Server function that adds double quote, I just don't recall.
>>
>>Not sure why do you need to add " in front and perhaps it would be easier to do some extra processing in VFP after you get results, but here I see problems
>>
>>'"' + cast('' as varchar(12)) WorkPhone + '"' AS WorkPhone,
>>
>>should be
>>
>>'"' + cast('' as varchar(12)) + '"' AS WorkPhone,
>>(and I guess you need to use char(12) and not varchar)
>>
>>You have same problems in other fields bellow.
>
>Looking much better, thanks. Getting another error now:
>
>
>Msg 245, Level 16, State 1, Line 2
>Conversion failed when converting the varchar value '"' to data type int.
>
>
>
>USE IMPACTMD
>GO
>
>SELECT
>	'"' + LastName + '"' AS LastName,
>	'"' + FirstName + '"' AS FirstName,
>	'"' + MI + '"' AS MI,
>	'"' + Address1 + '"' AS Address1,
>	'"' + Address2 + '"' AS Address2,
>	'"' + City + '"' AS City,
>	'"' + State + '"' AS State,
>	'"' + Zip + '"' AS Zip,
>	'"' + SSN + '"' AS SSN,
>	'"' + Phone + '"' AS Phone,
>	'"' + cast('' as varchar(12)) + '"' AS WorkPhone,
>	'"' + cast(DOB as varchar(12)) + '"' AS DOB,
>	'"' + Sex + '"' AS Sex,
>	'"' + InsCompanyID + '"' AS InsCompanyID,
>	'"' + InsCompanyID2 + '"' AS InsCompanyID2,
>	'"' + cast('' as varchar(12)) + '"' AS Reserved01,
>	'"' + cast('' as varchar(12)) + '"' AS Reserved02,
>	'"' + cast('' as varchar(12)) + '"' AS Reserved03,
>	'"' + cast('Family_Physician_Last_Name' as varchar(30)) + '"' AS Family_Physician_Last_Name,
>	'"' + cast('Family_Physician_First_Name' as varchar(30)) + '"' AS Family_Physician_First_Name,
>	'"' + cast('' as varchar(12)) + '"' AS Reserved04,
>	'"' + cast('Referring_Physician_Last_Name' as varchar(30)) + '"' AS Referring_Physician_Last_Name,
>	'"' + cast('Referring_Physician_First_Name' as varchar(30)) + '"' AS Referring_Physician_First_Name,
>	'"' + cast('' as varchar(12)) + '"' AS Reserved05,
>	'"' + Provider1 + '"' AS Provider1,
>	'"' + Provider2  + '"' AS Provider2
>	FROM Patients
>-- Just Testing!
>	WHERE ChartID = '1601'
>
>GO
>
>SET ANSI_PADDING OFF
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform