Bruce Gust
asked on
What does this error mean?
I start things off by creating a temporary table like this:
$sql_50 = "CREATE TABLE #tmp_Results
(
id int IDENTITY,
str_ProjectName varchar(150),
str_Tool varchar(150),
str_FullName varchar(150),
str_ProjectType varchar(150),
str_Description varchar(max),
str_TargetCompletionDate varchar(50),
dec_PercentageCompleted decimal(10,2),
str_ProjectId varchar(150),
int_ProjectRank int
)";
Then I run this query:
insert into #tmp_Results (
str_ProjectName,
str_Tool,
str_FullName,
str_Description,
str_ProjectType,
str_TargetCompletionDate,
dec_PercentageCompleted,
str_ProjectId,
int_ProjectRank)
VALUES (
'SA Pipeline Workbook',
'SA Portal (MVC)',
' ',
'Automate the SA Pipeline Report that is currently in xls form. Data currently pulled from multiple datasources including NETWorkflow.',
'New Feature',
'',
'',
'140618b',
'999')
...and I get this error:
Error converting data type varchar to numeric.
Pretty sure it has something to do with my decimal field, but I don't know what or how to fix it.
Thoughts?
$sql_50 = "CREATE TABLE #tmp_Results
(
id int IDENTITY,
str_ProjectName varchar(150),
str_Tool varchar(150),
str_FullName varchar(150),
str_ProjectType varchar(150),
str_Description varchar(max),
str_TargetCompletionDate varchar(50),
dec_PercentageCompleted decimal(10,2),
str_ProjectId varchar(150),
int_ProjectRank int
)";
Then I run this query:
insert into #tmp_Results (
str_ProjectName,
str_Tool,
str_FullName,
str_Description,
str_ProjectType,
str_TargetCompletionDate,
dec_PercentageCompleted,
str_ProjectId,
int_ProjectRank)
VALUES (
'SA Pipeline Workbook',
'SA Portal (MVC)',
' ',
'Automate the SA Pipeline Report that is currently in xls form. Data currently pulled from multiple datasources including NETWorkflow.',
'New Feature',
'',
'',
'140618b',
'999')
...and I get this error:
Error converting data type varchar to numeric.
Pretty sure it has something to do with my decimal field, but I don't know what or how to fix it.
Thoughts?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not familiar with the coding language you're using (what is it?), so on that point I'll step back to encourage other experts to respond.
ASKER
PHP
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I suggest trying code below, allowing SQL to do the work of replacing the blank with a NULL:
...
VALUES(
...
'$project[str_TargetComple tionDate]' ,
NULLIF('$dec_Percentage', ''),
'$project[str_ProjectId]',
...
...
VALUES(
...
'$project[str_TargetComple
NULLIF('$dec_Percentage', ''),
'$project[str_ProjectId]',
...
ASKER
Here's what I'm doing:
Open in new window
I'm trying to accommodate that situation where there's no value, yet even when I throw in "NULL," it doesn't seem to do anything.
Thoughts?