Getting error while executing the query. The issue after the "+HomePhone+
Seems syntax is wrong but i’m not able to sort it out.
Please help me to resolve the issue.
Query - “Insert Into School_Basic_Info Values ('”+Location+“‘,’”+MRN+“‘,’”+FirstName+“‘,’”+MiddleName+“‘,’”+LastName+“‘,’”+MothersMaiden+“‘,’”+DOB+“‘,’”+MartialStatus+“‘,’”+Height+“‘,’”+DICOM_ID+“‘,’”+X_Ray+“‘,’”+SNN+“‘,’”+Gender+“‘,’”+Language+“‘,’”+Weight+“‘,’”+AddLine1+“‘,’”+AddLine2+“‘,’”+City+“‘,’”+ZIP+“‘,’”+ZipDeta+“‘,’”+MobileNum+“‘,’”+EmailID+“‘,’”+ContactBy+“‘,’”+State+“‘,’”+WorkPhone+“‘,’”+HomePhone+“,‘+select cast(SWITCHOFFSET(SYSDATETIME(), ‘-05:00’) as datetime)+’)”
Error-

sarathi125
(Parthasarathi)
2
@vaibhav2.chavan,
Try by replacing the above highlighted part as
‘“+HomePhone+”’, '+Select
@sarathi125 - Tried but getting the same error-
‘“+HomePhone+”,’+Select cast(SWITCHOFFSET(SYSDATETIME(), ‘-05:00’) as datetime)+')"

@vaibhav2.chavan,
I dont have SQL with me right now, but checked this query with online sql query validator, so try as per the below.
Insert Into
School_Basic_Info
Values
(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'+select cast(SWITCHOFFSET(SYSDATETIME(), ' "-05:00" ') as datetime)+'
)