Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cast & Convert help

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
0
0
AU
I have an insert query that we use for populating data when submitted through our website, however even though the field allows 4000 characters it only ever submits up to 2700 so I need to allow it to submit up to 4000.

I was trying to alter my sql query with CAST and CONVERT but i keep getting the error of "incorrect syntaxt near the '(' and I don't know how to fix it or what to look for.

INSERT INTO RelocateeNotes (RelocateID, ReportNote, OutsidePolicy, EmailTo,
EmailTo2, DateCom, InputBy,
Cast(CommentNote as varchar(8000)) as CommentNote,
SupplierID, ProblemValue, WhoReportedTo,
DateReportedToSupplier, Outcome, KPIException, SupplierServiceAlert, RelocateeStatus,
OriginalRecordID, RealEstateStatus,Invoicing, InsuranceClaim) SELECT 7926, '0', '0', '0', '0', '13 May 2005',
ManagerID, 'test', NULL, '0', '0', NULL, NULL, 0, 0, 0, 237985, 0, 0, 0 FROM viewMatchUsersToManagers
WHERE UserID=(SELECT UserID FROM secUsers WHERE NetworkLogin='blah')


Can I use CAST or Convert in insert query like this i have never used it.

Thanks
 
You're trying to cast or convert the target field not the data. The initial bracketed field list in your statement (after the INSERT INTO tableName...) is telling the SQL the fields to insert into and you can't cast or convert a target field, only the data intended for it.

Rhys

""Vampireware /n/, a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die."

My Home
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top