Showing posts with label conversion. Show all posts
Showing posts with label conversion. Show all posts

Friday, March 23, 2012

Import from Access - Datatype conversions

I have to do a lot of inporting from Access files. Is there a place where I can change the default datatype conversion for Access Text from nvarchar to varchar?

Thanks.

Kato

If you are using the import wizard then you can affect this with the mapping files at:

%PROGRAMFILES%\Microsoft SQL Server\90\DTS\MappingFiles

I'm guessing that the one you want is JetToSSIS.xml

If you are building packages manually then you can change this in the source adapter.

-Jamie

|||

Outstanding. Exactly what I was looking for.

Thank you.

sql

Import export failed : Data conversion failed

[Source - chn_employee_vew_test_txt [1]] Error: Data conversion failed. The data conversion for column "Column 42" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

[Source - chn_employee_vew_test_txt [1]] Error: The "output column "Column 42" (136)" failed because truncation occurred, and the truncation row disposition on "output column "Column 42" (136)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.

I using Locale (People's Republic of China) and code page of 936 (Simplied Chinese GBK) with header row delimiter {CR}{LF}.

I am using flat file import method.

Whenever the server process the Column 42 with value "11,Nanjing Rd.W, China" which contain 'comma' or '.' it will hit error importing with above message. When i manually change the column value to non comma or '.' (11 Nanjing Rd W China) in the flat file it is ok.

I am using SQL server 2005.

Please advise what need to be done to avoid this error ?

Thanks in advance and any idea or suggestion is very much appreciated as i have try to solve this issue for over a week but still not able to find any answer on it.

Please help.

regards,

kong

Check the Quoted_Identifier and text_qualifier values in SSIS, if you are running from a workstation then make sure SSIS server component is installed

Wednesday, March 21, 2012

Import Domino data to SQL Server

We are going to do a conversion from a Domino server to a SQL Server
database. DTS is the obvious choice for importing data from a .csv or
similar into SQL Server, but is there a recommended way of automating the
export of the Domino data to a set of .csv or similar?
I'd love to connect directly using ODBC/OLE DB, but I'm not sure if that is
an option.
Any guidance would be appreciated. Thanks in advance.
Mark
Hi Mark,
Yes, your Domino could connect directly to SQL Server via ODBC Driver / OLE
DB provider.
Based on my scope, NotesSQL is an ODBC (Open Database Connectivity) driver
for Notes and Domino. With NotesSQL, end users and application developers
can integrate Domino data with their applications using tools such as
Access and SQL Server. See the following links for more detailed information
Lotus NotesSQL
http://www.lotus.com/products/produc...84085256e20006
db691?OpenDocument
With NotesSQL, you are able to DTS directly
Hope it helps and if you have any questions or concerns, don't hesitate to
let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!
|||Hi Mark,
I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!
Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

Import Domino data to SQL Server

We are going to do a conversion from a Domino server to a SQL Server
database. DTS is the obvious choice for importing data from a .csv or
similar into SQL Server, but is there a recommended way of automating the
export of the Domino data to a set of .csv or similar?
I'd love to connect directly using ODBC/OLE DB, but I'm not sure if that is
an option.
Any guidance would be appreciated. Thanks in advance.
MarkHi Mark,
Yes, your Domino could connect directly to SQL Server via ODBC Driver / OLE
DB provider.
Based on my scope, NotesSQL is an ODBC (Open Database Connectivity) driver
for Notes and Domino. With NotesSQL, end users and application developers
can integrate Domino data with their applications using tools such as
Access and SQL Server. See the following links for more detailed information
Lotus NotesSQL
http://www.lotus.com/products/produ...584085256e20006
db691?OpenDocument
With NotesSQL, you are able to DTS directly
Hope it helps and if you have any questions or concerns, don't hesitate to
let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||Hi Mark,
I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!
Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

Import Domino data to SQL Server

We are going to do a conversion from a Domino server to a SQL Server
database. DTS is the obvious choice for importing data from a .csv or
similar into SQL Server, but is there a recommended way of automating the
export of the Domino data to a set of .csv or similar?
I'd love to connect directly using ODBC/OLE DB, but I'm not sure if that is
an option.
Any guidance would be appreciated. Thanks in advance.
MarkHi Mark,
Yes, your Domino could connect directly to SQL Server via ODBC Driver / OLE
DB provider.
Based on my scope, NotesSQL is an ODBC (Open Database Connectivity) driver
for Notes and Domino. With NotesSQL, end users and application developers
can integrate Domino data with their applications using tools such as
Access and SQL Server. See the following links for more detailed information
Lotus NotesSQL
http://www.lotus.com/products/product4.nsf/wdocs/3243f3d81944584085256e20006
db691?OpenDocument
With NotesSQL, you are able to DTS directly:)
Hope it helps and if you have any questions or concerns, don't hesitate to
let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||Hi Mark,
I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!
Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

Friday, March 9, 2012

Import Data Error- Insert Error

I'm trying to use the import wizard in a database
conversion. I get 1 error in this process that states...
--
Insert error, column 23 ('PAY_PERIOD',DBTYPE-DBTIMESTAMP),
status 6: Data overflow. Invalid character value for cast
specification.
--
The tables are there after the conversion. The data is
not. During the import wizard process, I can preview the
table and the data is in the columns. Only when I go to
convert does it lose the data.
If it was the columns that were the problem, I'd re-
program the code. But I need this data transfered over.
Please HelpI'm guessing this is caused because you have some invalid data in your
PAY_PERIOD field in the input record. You need to review your input data
and verify that all data in the PAY_PERIOD field do in fact contain valid
dates. One option would be to put the data into a temporary table where the
PAY_PERIOD is just character data. You could then review the PAY_PERIOD
column in the temporary table and fix up any data that is not a valid date.
Once all the data is fixed you can then insert the data into the target you
desire from the temporary table.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Steve" <anonymous@.discussions.microsoft.com> wrote in message
news:1ca4501c45324$26b7bc00$a601280a@.phx.gbl...
> I'm trying to use the import wizard in a database
> conversion. I get 1 error in this process that states...
> --
> Insert error, column 23 ('PAY_PERIOD',DBTYPE-DBTIMESTAMP),
> status 6: Data overflow. Invalid character value for cast
> specification.
> --
> The tables are there after the conversion. The data is
> not. During the import wizard process, I can preview the
> table and the data is in the columns. Only when I go to
> convert does it lose the data.
> If it was the columns that were the problem, I'd re-
> program the code. But I need this data transfered over.
> Please Help

Wednesday, March 7, 2012

Import conversion error caused by spaces?

I am trying to import a fixed width file where some of the numeric columns are empty. The columns in question are defined as integer columns (of varying sizes) and I am guessing that "empty" columns come across as multiple spaces on the import.

Even though I have "Retain null values from source" checked off, I am still receiving the following error on these empty columns:

Error: 0xC02020A1 at Input Data, Flat File Source [1]: Data conversion failed. The data conversion for column "ToContractExpiryYear" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
Error: 0xC0209029 at Input Data, Flat File Source [1]: The "output column "ToContractExpiryYear" (51)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "ToContractExpiryYear" (51)" specifies failure on error. An error occurred on the specified object of the specified component.
Error: 0xC0202092 at Input Data, Flat File Source [1]: An error occurred while processing file "\\Nastinus-01\ClearingData\OCC\20060320\ser2mst.20060317" on data row 1.

If it is truly the system treating the column as spaces (and not trimming the value), then the only solution I can think off is to source everything as strings, perform a transform that executes a Trim() (Derived Column or Script ?), THEN perform a transform that converts data types, then do whatever else I need...

Am I missing something? Is this the correct solution?

Hi,

On your Flat File Source, try to set the error Output, error column to "Ignore failure".

Then carefully review the result with a data viewer. It appears that you get NULL when there is no value.

Philippe

|||

This solution appears to work well, but is not a realistic solution where you wish to catch true errors (such as alpha data in numeric fields).

One would assume there is an option for fixed width input, to treat blank numeric fields as null. But there are none I can find. Is there any additional information on this subject?

Chris

Import conversion error caused by spaces?

I am trying to import a fixed width file where some of the numeric columns are empty. The columns in question are defined as integer columns (of varying sizes) and I am guessing that "empty" columns come across as multiple spaces on the import.

Even though I have "Retain null values from source" checked off, I am still receiving the following error on these empty columns:

Error: 0xC02020A1 at Input Data, Flat File Source [1]: Data conversion failed. The data conversion for column "ToContractExpiryYear" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
Error: 0xC0209029 at Input Data, Flat File Source [1]: The "output column "ToContractExpiryYear" (51)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "ToContractExpiryYear" (51)" specifies failure on error. An error occurred on the specified object of the specified component.
Error: 0xC0202092 at Input Data, Flat File Source [1]: An error occurred while processing file "\\Nastinus-01\ClearingData\OCC\20060320\ser2mst.20060317" on data row 1.

If it is truly the system treating the column as spaces (and not trimming the value), then the only solution I can think off is to source everything as strings, perform a transform that executes a Trim() (Derived Column or Script ?), THEN perform a transform that converts data types, then do whatever else I need...

Am I missing something? Is this the correct solution?

Hi,

On your Flat File Source, try to set the error Output, error column to "Ignore failure".

Then carefully review the result with a data viewer. It appears that you get NULL when there is no value.

Philippe

|||

This solution appears to work well, but is not a realistic solution where you wish to catch true errors (such as alpha data in numeric fields).

One would assume there is an option for fixed width input, to treat blank numeric fields as null. But there are none I can find. Is there any additional information on this subject?

Chris

Sunday, February 19, 2012

Implicit Text to Binary Conversion

/***
Requirement: Insert ascii text into varbinary field allowing SQL to convert
the data implicitly
Problem: The data is encoded as Unicode and is truncated or simply blanked
out after the first 10 characters
The following is valid and works; however, it doesn't solve my problem.
As a result, I've tried several approaches, including creating a cursor and
calling Cast() to convert the data to binary. This appears to work, but
again, stops after the first 10 characters
**/
DECLARE @.docHandle int
DECLARE @.xmlDoc varchar(5000)
SET @.xmlDoc ='
<?xml version="1.0"?>
<f2dbarchive>
<archive_timestamp datetime="2004-Sep-27 12:28:48 AM" />
<archive_test id="1530" />
<!-- tables used in this archive -->
<tables>
<Row txtTablename="tblFinalData" txtKeyName="lngInstanceID"
lngKeyValue="2096" lngRecordCount="4" />
</tables>
<!-- data from the tables -->
<data>
<tblFinalData>
<Row lngDataID="5336" lngInstanceID="2096" binData="10946534210000000000276
Final
35031.16534415632448.030617561162.062056640780.437 87345288720.529611595975413.8801526137533849.47590 9519025.77227602431221.58205664078257.545
0.085 DUST SPOTTER 3 LOF 85.00
NY3849.475909519025.7722760243122.0620566407829311 98.67 32086.86
160 85 31198.67 32086.86
140.48 85 0 0 1656
Y Y34149.809 33025.014 168.247 TOWER @. 5B SOUTH PED
123.21566117 -0.30555699 0.0010055 0.00555699
162.7038151636657.46 2017 Y Y34642.169 33069.594
172.887 MND 5.5B_NEW
147.95450669 -0.39920593 0.02882665 0.34920593 167.814226706570
2019 N N31198.912 32050.403 140.93 GP
8 OBS PT 0 0
-0.000382 0.01695564 0 0 1658 Y
Y35282.726 33023.024 175.67 TOWER @. 6B SOUTH PED
203.64517087 -1.08627593 0.00482913 0.03627593
163.7961106000857.63 2015 N N31892.772 32960.261
153.253 OBS PT 3B SOUTH 0
0 0.00531249 0.11706955 0 0
"
intPackageCount="" booGood="1" txtShotID="" txtStatus="Field" qvTime="0" />
<Row lngDataID="5337" lngInstanceID="2096" binData="10946539640000000000277
Final
34900.43868810932427.234930849677.0883333717911.85 11700763559.4096332145782681.194252534983717.38436 4552516.449301983071536.608333371790
0 1ST LIGHT SPOTTER 3
NY3717.384364552516.449301983071517.08833337179311 98.67
32086.86 160 85 31198.67
32086.86 140.48 85 0 0 1656
Y Y34149.809 33025.014 168.247 TOWER @. 5B SOUTH
PED 128.4489945 34.57777634 0.0010055
0.00555699 829.755965865400 2017 Y Y34642.169
33069.594 172.887 MND 5.5B_NEW
158.30450669 44.65079407 0.02882665 0.34920593
856.898004060910 2019 N N31198.912 32050.403
140.93 GP 8 OBS PT 0
0 -0.000382 0.01695564 0 0 1658
N N35282.726 33023.024 175.67 TOWER @. 6B
SOUTH PED 0 0
0.00482913 0.03627593 0 0 2015 Y
Y31892.772 32960.261 153.253 OBS PT 3B SOUTH
100.09468751 12.76626379 0.00531249 0.11706955
845.995612034910
" intPackageCount="" booGood="1" txtShotID=""
txtStatus="Field" qvTime="0" />
</tblFinalData>
</data>
</f2dbarchive>'
EXEC sp_xml_preparedocument @.docHandle OUTPUT, @.xmlDoc
DECLARE @.tableName varchar(80)
DECLARE @.instID int
SET @.instID=2096
SET @.tableName='tblFinalData'
IF(SELECT lngRecordCount FROM OPENXML(@.docHandle,
'/f2dbarchive/tables/Row', 1)
WITH (txtTablename varchar(80), lngRecordCount int)
WHERE txtTablename=@.tableName) > 0
BEGIN
print 'at least 1 row in '+@.tableName
INSERT INTO tblFinalData
(lngInstanceID, binData, intPackageCount, booGood, txtShotID, txtStatus,
qvTime)
SELECT @.instID, cast(binData as varbinary) as binData, intPackageCount,
booGood, txtShotID, txtStatus, qvTime
FROM OpenXML(@.docHandle, '/f2dbarchive/data/tblFinalData/Row', 1)
WITH (
lngInstanceID int,
binData varbinary(2000),
intPackageCount int,
booGood bit,
txtShotID char(10),
txtStatus char(10),
qvTime decimal(16, 6)
)
END
ELSE
BEGIN
print '0 records in ' + @.tableName
END
EXEC sp_xml_removedocument @.docHandle
/**
--undesired unicode results: 1) it's unicode and 2) the data is blank after
the first number is translated
0x310030003900340036003500330039003600340030003000 300030003000
...
0x310030003900340036003500330034003200310030003000 300030003000
...
--normal result using vb
0x313039343635353933393030303030303030303032373920 20202020202046696E616C2020202020333531...
**/
The XML is Unicode once it is parsed. If you want to get it into
non-Unicode, change

> binData varbinary(2000),
to

> binData varchar(8000),
in your WITH clause.
HTH
Michael
"TeraComp in Florida" <TeraComp in Florida@.discussions.microsoft.com> wrote
in message news:3F1475DE-B508-4F80-B7DF-68C40E627FAD@.microsoft.com...
> /***
> Requirement: Insert ascii text into varbinary field allowing SQL to
> convert
> the data implicitly
> Problem: The data is encoded as Unicode and is truncated or simply
> blanked
> out after the first 10 characters
> The following is valid and works; however, it doesn't solve my problem.
> As a result, I've tried several approaches, including creating a cursor
> and
> calling Cast() to convert the data to binary. This appears to work, but
> again, stops after the first 10 characters
> **/
> DECLARE @.docHandle int
> DECLARE @.xmlDoc varchar(5000)
> SET @.xmlDoc ='
> <?xml version="1.0"?>
> <f2dbarchive>
> <archive_timestamp datetime="2004-Sep-27 12:28:48 AM" />
> <archive_test id="1530" />
> <!-- tables used in this archive -->
> <tables>
> <Row txtTablename="tblFinalData" txtKeyName="lngInstanceID"
> lngKeyValue="2096" lngRecordCount="4" />
> </tables>
> <!-- data from the tables -->
> <data>
> <tblFinalData>
> <Row lngDataID="5336" lngInstanceID="2096"
> binData="10946534210000000000276
> Final
> 35031.16534415632448.030617561162.062056640780.437 87345288720.529611595975413.8801526137533849.47590 9519025.77227602431221.58205664078257.545
> 0.085 DUST SPOTTER 3 LOF 85.00
> NY3849.475909519025.7722760243122.0620566407829311 98.67
> 32086.86
> 160 85 31198.67 32086.86
> 140.48 85 0 0 1656
> Y Y34149.809 33025.014 168.247 TOWER @. 5B SOUTH PED
> 123.21566117 -0.30555699 0.0010055 0.00555699
> 162.7038151636657.46 2017 Y Y34642.169 33069.594
> 172.887 MND 5.5B_NEW
> 147.95450669 -0.39920593 0.02882665 0.34920593
> 167.814226706570
> 2019 N N31198.912 32050.403 140.93
> GP
> 8 OBS PT 0 0
> -0.000382 0.01695564 0 0 1658
> Y
> Y35282.726 33023.024 175.67 TOWER @. 6B SOUTH PED
> 203.64517087 -1.08627593 0.00482913 0.03627593
> 163.7961106000857.63 2015 N N31892.772 32960.261
> 153.253 OBS PT 3B SOUTH 0
> 0 0.00531249 0.11706955 0 0
> "
> intPackageCount="" booGood="1" txtShotID="" txtStatus="Field" qvTime="0"
> />
> <Row lngDataID="5337" lngInstanceID="2096"
> binData="10946539640000000000277
> Final
> 34900.43868810932427.234930849677.0883333717911.85 11700763559.4096332145782681.194252534983717.38436 4552516.449301983071536.608333371790
> 0 1ST LIGHT SPOTTER 3
> NY3717.384364552516.449301983071517.08833337179311 98.67
> 32086.86 160 85 31198.67
> 32086.86 140.48 85 0 0 1656
> Y Y34149.809 33025.014 168.247 TOWER @. 5B
> SOUTH
> PED 128.4489945 34.57777634 0.0010055
> 0.00555699 829.755965865400 2017 Y Y34642.169
> 33069.594 172.887 MND 5.5B_NEW
> 158.30450669 44.65079407 0.02882665 0.34920593
> 856.898004060910 2019 N N31198.912 32050.403
> 140.93 GP 8 OBS PT 0
> 0 -0.000382 0.01695564 0 0
> 1658
> N N35282.726 33023.024 175.67 TOWER @. 6B
> SOUTH PED 0 0
> 0.00482913 0.03627593 0 0 2015
> Y
> Y31892.772 32960.261 153.253 OBS PT 3B SOUTH
> 100.09468751 12.76626379 0.00531249 0.11706955
> 845.995612034910
> " intPackageCount="" booGood="1" txtShotID=""
> txtStatus="Field" qvTime="0" />
> </tblFinalData>
> </data>
> </f2dbarchive>'
> EXEC sp_xml_preparedocument @.docHandle OUTPUT, @.xmlDoc
> DECLARE @.tableName varchar(80)
> DECLARE @.instID int
> SET @.instID=2096
> SET @.tableName='tblFinalData'
> IF (SELECT lngRecordCount FROM OPENXML(@.docHandle,
> '/f2dbarchive/tables/Row', 1)
> WITH (txtTablename varchar(80), lngRecordCount int)
> WHERE txtTablename=@.tableName) > 0
> BEGIN
> print 'at least 1 row in '+@.tableName
> INSERT INTO tblFinalData
> (lngInstanceID, binData, intPackageCount, booGood, txtShotID, txtStatus,
> qvTime)
> SELECT @.instID, cast(binData as varbinary) as binData, intPackageCount,
> booGood, txtShotID, txtStatus, qvTime
> FROM OpenXML(@.docHandle, '/f2dbarchive/data/tblFinalData/Row', 1)
> WITH (
> lngInstanceID int,
> binData varbinary(2000),
> intPackageCount int,
> booGood bit,
> txtShotID char(10),
> txtStatus char(10),
> qvTime decimal(16, 6)
> )
> END
> ELSE
> BEGIN
> print '0 records in ' + @.tableName
> END
>
> EXEC sp_xml_removedocument @.docHandle
> /**
> --undesired unicode results: 1) it's unicode and 2) the data is blank
> after
> the first number is translated
> 0x310030003900340036003500330039003600340030003000 300030003000
> ...
> 0x310030003900340036003500330034003200310030003000 300030003000
> ...
> --normal result using vb
> 0x313039343635353933393030303030303030303032373920 20202020202046696E616C2020202020333531...
> **/
|||Thanks...that's great...gets me past creating a cursor. If I may be so dense
to ask one more issue:
After processing, this is all I get:
0x313039343635333432313030303030303030303032373620 202020202020
From a source string of:
10946534210000000000276 Final
35031.16534415632448.030617561162.062056640780.437 8734528 {the string is
actually about 1600 characters wide}
Is there something wrong with mixed numeric/text?
Any followup is greatly appreciated.
Dave
"Michael Rys [MSFT]" wrote:

> The XML is Unicode once it is parsed. If you want to get it into
> non-Unicode, change
>
> to
>
> in your WITH clause.
> HTH
> Michael
> "TeraComp in Florida" <TeraComp in Florida@.discussions.microsoft.com> wrote
> in message news:3F1475DE-B508-4F80-B7DF-68C40E627FAD@.microsoft.com...
>
>
|||I've discovered that cast(binData as binary(2000)) properly stores the data.
My guess is SQL Sever see the space as a field terminator and stops
processing.
If this is right, the follow-on question should be, how do I force SQL to
read the entire data word?
Or am I stuck with fixed width binary data? (incidently, the reason for
using a varbinary column was for efficiency)
Thanks again...I'm feeling close to resolving my delimma.
Dave
"TeraComp in Florida" wrote:
[vbcol=seagreen]
> Thanks...that's great...gets me past creating a cursor. If I may be so dense
> to ask one more issue:
> After processing, this is all I get:
> 0x313039343635333432313030303030303030303032373620 202020202020
> From a source string of:
> 10946534210000000000276 Final
> 35031.16534415632448.030617561162.062056640780.437 8734528 {the string is
> actually about 1600 characters wide}
> Is there something wrong with mixed numeric/text?
> Any followup is greatly appreciated.
> Dave
> "Michael Rys [MSFT]" wrote:
|||How do you check? If you use the query analyzer, did you set the column
width large enough?
The space should not be treated as a field terminator...
Best regards
Michael
"TeraComp in Florida" <TeraCompinFlorida@.discussions.microsoft.com> wrote in
message news:FD29C515-44BF-4A4A-A61B-0290738F0AB8@.microsoft.com...[vbcol=seagreen]
> I've discovered that cast(binData as binary(2000)) properly stores the
> data.
> My guess is SQL Sever see the space as a field terminator and stops
> processing.
> If this is right, the follow-on question should be, how do I force SQL to
> read the entire data word?
> Or am I stuck with fixed width binary data? (incidently, the reason for
> using a varbinary column was for efficiency)
> Thanks again...I'm feeling close to resolving my delimma.
> Dave
> "TeraComp in Florida" wrote:
|||Found the bug:
cast(binData as varbinary) as binData
Should be
cast(binData as varbinary(2000)) as binData
SQL Server was kind enough to all the former, but this allow it to determine
the length of the varBinary data.
Many thanks to Michael Rys for expert guidance.
Dave
"TeraComp in Florida" wrote:
[vbcol=seagreen]
> I've discovered that cast(binData as binary(2000)) properly stores the data.
> My guess is SQL Sever see the space as a field terminator and stops
> processing.
> If this is right, the follow-on question should be, how do I force SQL to
> read the entire data word?
> Or am I stuck with fixed width binary data? (incidently, the reason for
> using a varbinary column was for efficiency)
> Thanks again...I'm feeling close to resolving my delimma.
> Dave
> "TeraComp in Florida" wrote:
|||Yes I use QA using select len(bindata) as ldata, bindata from tblFinalData
That eventually led me to discover the need for cast(binData as
varbinary(2000))
which solves my problem.
It would be noteworthy to discover why SQL Server stopped parsing the text
Try this:
Sql#1: select cast('1094653421000000000027635031.16534415632448. 03061756'
as varbinary) as tdata
Sql#2: select cast('1094653421000000000027635031.16534415632448. 03061756' as
varbinary(100)) as tdata
The results I get are
#1 is truncated to 30 characters (doesn't matter what characters)
#2 is complete and variable as expected
Therefore: (with my Florida hurricane-ridden mind), SQL Server's cast
function defaults to 30-characters. [guess I missed that in the Books-Online]
Dave
cast('somedata' as
"Michael Rys [MSFT]" wrote:

> How do you check? If you use the query analyzer, did you set the column
> width large enough?
> The space should not be treated as a field terminator...
> Best regards
> Michael
> "TeraComp in Florida" <TeraCompinFlorida@.discussions.microsoft.com> wrote in
> message news:FD29C515-44BF-4A4A-A61B-0290738F0AB8@.microsoft.com...
>
>
|||Hmm. I should have seen this (mea culpa) as well.
In SQL Server 2005, you probably want to use varbinary(max) instead :-).
Best regards
Michael
"TeraComp in Florida" <TeraCompinFlorida@.discussions.microsoft.com> wrote in
message news:2233608D-86CD-4EF3-AFCE-E22C274A8216@.microsoft.com...[vbcol=seagreen]
> Found the bug:
> cast(binData as varbinary) as binData
> Should be
> cast(binData as varbinary(2000)) as binData
> SQL Server was kind enough to all the former, but this allow it to
> determine
> the length of the varBinary data.
> Many thanks to Michael Rys for expert guidance.
> Dave
>
> "TeraComp in Florida" wrote:

Implicit conversion of datatype text to nvarchar is not allowed.

I am facing a problem while using SQL Server with VB application.

Implicit conversion from datatype text to nvarchar is not allowed.
Use the convert function to run this query.

When i see the trace file, i see one stored procedure called but no
lines of code get executed, and immediately after that the ROLLBACK
TRANSACTION occurs and the applications fails.

But to my surprise i am able to do the same thing on a different
machine using the same application and the same database on the same
server with the same user id.

Can anyone explain the reason of occurance of this problem.

I require this very urgently, so i will be oblized if anyone can come
up with a quick response.

Kind Regards,
Amit KumarAmit (kumar_amit@.delhi.tcs.co.in) writes:
> I am facing a problem while using SQL Server with VB application.
> Implicit conversion from datatype text to nvarchar is not allowed.
> Use the convert function to run this query.
> When i see the trace file, i see one stored procedure called but no
> lines of code get executed, and immediately after that the ROLLBACK
> TRANSACTION occurs and the applications fails.
> But to my surprise i am able to do the same thing on a different
> machine using the same application and the same database on the same
> server with the same user id.
> Can anyone explain the reason of occurance of this problem.

It seems that the procedure has a parameter of the type nvarchar, but
the application tries to pass a text parameter.

Is that really the same executable you run on the two machines. Or could
it be that they are two different versions, and the bug has been fixed in
one of them?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns9415F30B91F6DYazorman@.127.0.0.1>...
> Amit (kumar_amit@.delhi.tcs.co.in) writes:
> > I am facing a problem while using SQL Server with VB application.
> > Implicit conversion from datatype text to nvarchar is not allowed.
> > Use the convert function to run this query.
> > When i see the trace file, i see one stored procedure called but no
> > lines of code get executed, and immediately after that the ROLLBACK
> > TRANSACTION occurs and the applications fails.
> > But to my surprise i am able to do the same thing on a different
> > machine using the same application and the same database on the same
> > server with the same user id.
> > Can anyone explain the reason of occurance of this problem.
> It seems that the procedure has a parameter of the type nvarchar, but
> the application tries to pass a text parameter.
> Is that really the same executable you run on the two machines. Or could
> it be that they are two different versions, and the bug has been fixed in
> one of them?

No both the executables are exactly the same, and we are not passing
any text parameters via the application.

Also i found that there may be a problem due to some ODBC drivers not
able to adjust with the UNICODE datatypes. Because if the change the
datatype to non-Unicode then things work on fine. Now i want to know
what may the specific reason for the problems with non-unicode
datatypes...may be the windows NT or the ODBC drivers are the catch.
But i am not sure what and where to search for these.

Thanks,
Amit Kumar|||Amit (kumar_amit@.delhi.tcs.co.in) writes:
> Also i found that there may be a problem due to some ODBC drivers not
> able to adjust with the UNICODE datatypes. Because if the change the
> datatype to non-Unicode then things work on fine. Now i want to know
> what may the specific reason for the problems with non-unicode
> datatypes...may be the windows NT or the ODBC drivers are the catch.
> But i am not sure what and where to search for these.

Sounds like you should make sure that the machines have some good version
of the MDAC installed. Search around at www.microsoft.com. The MDAC
Component Checker can be a good thing to start with, although I've found
that it can get confused, if you have some newer version it does not
know about.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns9417425FAA96Yazorman@.127.0.0.1>...
> Amit (kumar_amit@.delhi.tcs.co.in) writes:
> > Also i found that there may be a problem due to some ODBC drivers not
> > able to adjust with the UNICODE datatypes. Because if the change the
> > datatype to non-Unicode then things work on fine. Now i want to know
> > what may the specific reason for the problems with non-unicode
> > datatypes...may be the windows NT or the ODBC drivers are the catch.
> > But i am not sure what and where to search for these.
> Sounds like you should make sure that the machines have some good version
> of the MDAC installed. Search around at www.microsoft.com. The MDAC
> Component Checker can be a good thing to start with, although I've found
> that it can get confused, if you have some newer version it does not
> know about.

I have already tried re-installation of the MDAC 2.5 but it did not
help me.
Can you give me idea if the regional settinngs could have created the
problem.
If yes, what must be the settings that creates this problem.

Also i found out that the Active Code Pages (ACP) also has an affect
and could be a reason for this problem. Do you have any idea of Active
Code Pages.

Thanks & Regards,
Amit|||Amit (kumar_amit@.delhi.tcs.co.in) writes:
> I have already tried re-installation of the MDAC 2.5 but it did not
> help me.
> Can you give me idea if the regional settinngs could have created the
> problem.
> If yes, what must be the settings that creates this problem.
> Also i found out that the Active Code Pages (ACP) also has an affect
> and could be a reason for this problem. Do you have any idea of Active
> Code Pages.

I thought ACP was for ANSI Code Page, but I could be wrong.

I don't really see where the regional settings would come in here, but
I've been wrong before.

Anyway, I have to admit that I am bit stumped. Is it possible for you
to share the source code that is causing the problem, both on the client
side and SQL Server side?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Implicit Conversion in Query Analyzer

I am trying to construct a query in Query Analyzer (with SQL Server 2000), but am getting an error regarding "implicit conversion."

Here is the query:

SELECT dbo.AUCTION.EbayNum, dbo.AUCTION.EndDate,
DATENAME([month], dbo.AUCTION.EndDate) + ' ' + DATENAME([year], dbo.AUCTION.EndDate) AS [PmtMonth],
dbo.LOT.Description, dbo.AUCTION.WinBid,
PaidStat = CASE dbo.AUCTION.PaidStatus
WHEN 0 THEN ''
ELSE 'PAID'
END,
PaidAmt = CASE dbo.AUCTION.PaidStatus
WHEN 0 THEN ''
ELSE dbo.AUCTION.WinBid
END
FROM dbo.AUCTION INNER JOIN
dbo.LOT ON dbo.AUCTION.LotNum = dbo.LOT.LotNum
WHERE (LEN(dbo.AUCTION.Winner) > 0)

The error occurs in the PaidAmt CASE statment:
"Implicit conversion from data type varchar to money is not allowed. Use the CONVERT function to run this query."

Why is there an implicit conversion going on? And how can I fix it? :mad:Maybe here:?

PaidAmt = CASE dbo.AUCTION.PaidStatus
WHEN 0 THEN ''

You are trying to insert a zero-length string into the PaidAmt column (presumably money datatype).

Try this instead:

PaidAmt = CASE dbo.AUCTION.PaidStatus
WHEN 0 THEN NULL|||Woo hoo! Thanks -- I forgot to try that. :)

Implicit conversion from string to date

Hello,
I am getting the message Implicit conversion from string to date...
Please help
Protected Sub btnShowDetails_Click(ByVal sender As Object, ByVal e As
EventArgs) Handles btnShowDetails.Click
Dim startdate As String = txtStartDate.Text
Dim enddate As String = txtEndDate.Text
'startdate = Convert.ToDateTime(startdate as date)
GRCallHistory.DataSource = getcallhistory("PhoneNumber",
"StartDate", "EndDate")
GRCallHistory.DataBind()
End Sub
Function getcallhistory(ByVal Phonenumber As String, _
ByVal StartDate As DateTime, _
ByVal enddate As DateTime) As
System.Data.SqlClient.SqlDataReader
Dim Connectionstring As String =
"Server=192.168.225. 8;Database=Wiband;uid=Wiband;password=op
tiplex"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(Connectionstring)
Dim querystring As String = "select SUBSTRING(CAST(calldate AS
VARCHAR(20)), 1, 11) AS CallDate, SUBSTRING(CAST(calldate AS
VARCHAR(20)), 12, 13) AS CallTime, PhoneNumber, minutes,
calldescription, charge from
voipcalls.dbo.fw_fnVOIPGetCustCallHistory('" & Phonenumber & "', '" &
StartDate & "', '" & enddate & "', 0, -1)"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand(querystring, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader =
sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End FunctionWell, what does the string you are trying to cast look like? You can't
expect people here to take your .NET code, build an application, and make
assumptions about what is actually being passed into values for StartDate
and EndDate. Heck, a lot of people here don't even have .NET installed.
So, please try to demonstrate what you're trying to convert to a DATETIME
with something a little more direct, e.g.
SELECT CONVERT(DATETIME, 'some string')
A
<lizansi@.gmail.com> wrote in message
news:1127400225.270131.95980@.g49g2000cwa.googlegroups.com...
> Hello,
> I am getting the message Implicit conversion from string to date...
> Please help
> Protected Sub btnShowDetails_Click(ByVal sender As Object, ByVal e As
> EventArgs) Handles btnShowDetails.Click
> Dim startdate As String = txtStartDate.Text
> Dim enddate As String = txtEndDate.Text
> 'startdate = Convert.ToDateTime(startdate as date)
>
> GRCallHistory.DataSource = getcallhistory("PhoneNumber",
> "StartDate", "EndDate")
> GRCallHistory.DataBind()
> End Sub
> Function getcallhistory(ByVal Phonenumber As String, _
> ByVal StartDate As DateTime, _
> ByVal enddate As DateTime) As
> System.Data.SqlClient.SqlDataReader
> Dim Connectionstring As String =
> "Server=192.168.225. 8;Database=Wiband;uid=Wiband;password=op
tiplex"
> Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
> System.Data.SqlClient.SqlConnection(Connectionstring)
> Dim querystring As String = "select SUBSTRING(CAST(calldate AS
> VARCHAR(20)), 1, 11) AS CallDate, SUBSTRING(CAST(calldate AS
> VARCHAR(20)), 12, 13) AS CallTime, PhoneNumber, minutes,
> calldescription, charge from
> voipcalls.dbo.fw_fnVOIPGetCustCallHistory('" & Phonenumber & "', '" &
> StartDate & "', '" & enddate & "', 0, -1)"
> Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
> System.Data.SqlClient.SqlCommand(querystring, sqlConnection)
> sqlConnection.Open()
> Dim dataReader As System.Data.SqlClient.SqlDataReader =
> sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
>|||I hope your SQL server sits behind a DMZ (for your sake)
Anyway the problem is here
dbo.fw_fnVOIPGetCustCallHistory('" & Phonenumber & "', '" &
StartDate & "', '" & enddate & "', 0, -1)"
StartDate and enddate are not formatted well
http://sqlservercode.blogspot.com/
"lizansi@.gmail.com" wrote:

> Hello,
> I am getting the message Implicit conversion from string to date...
> Please help
> Protected Sub btnShowDetails_Click(ByVal sender As Object, ByVal e As
> EventArgs) Handles btnShowDetails.Click
> Dim startdate As String = txtStartDate.Text
> Dim enddate As String = txtEndDate.Text
> 'startdate = Convert.ToDateTime(startdate as date)
>
> GRCallHistory.DataSource = getcallhistory("PhoneNumber",
> "StartDate", "EndDate")
> GRCallHistory.DataBind()
> End Sub
> Function getcallhistory(ByVal Phonenumber As String, _
> ByVal StartDate As DateTime, _
> ByVal enddate As DateTime) As
> System.Data.SqlClient.SqlDataReader
> Dim Connectionstring As String =
> "Server=192.168.225. 8;Database=Wiband;uid=Wiband;password=op
tiplex"
> Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
> System.Data.SqlClient.SqlConnection(Connectionstring)
> Dim querystring As String = "select SUBSTRING(CAST(calldate AS
> VARCHAR(20)), 1, 11) AS CallDate, SUBSTRING(CAST(calldate AS
> VARCHAR(20)), 12, 13) AS CallTime, PhoneNumber, minutes,
> calldescription, charge from
> voipcalls.dbo.fw_fnVOIPGetCustCallHistory('" & Phonenumber & "', '" &
> StartDate & "', '" & enddate & "', 0, -1)"
> Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
> System.Data.SqlClient.SqlCommand(querystring, sqlConnection)
> sqlConnection.Open()
> Dim dataReader As System.Data.SqlClient.SqlDataReader =
> sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
>|||sorry aaron, this was the first time i ever joined google
group...basically it's taking two arguments from a text box that is
startdate and enddate and pass it to the sql function. this function
has both the parameters as datetime.|||Yes, I understand how the program works. Now show some example input from
the text box. And do whatyou can to standardize this, e.g. have them pick
from a calendar and build the date for them. If you allow them free text
entry, they're going to enter all kinds of invalid crap. What date is
05/06/04? Is that May 6th 2004, or June 5th 2004, or April 6th 2005? How
about 05/13/03? And 7/5/2006? 04/13/13?
<lizansi@.gmail.com> wrote in message
news:1127401135.824457.280650@.g43g2000cwa.googlegroups.com...
> sorry aaron, this was the first time i ever joined google
> group...basically it's taking two arguments from a text box that is
> startdate and enddate and pass it to the sql function. this function
> has both the parameters as datetime.
>|||aaron, I have people input the date in format 08/01/2005...this is
mandatory|||Okay, so show an actual value that fails!
<lizansi@.gmail.com> wrote in message
news:1127403625.223935.182810@.g43g2000cwa.googlegroups.com...
> aaron, I have people input the date in format 08/01/2005...this is
> mandatory
>|||select SUBSTRING(CAST (calldate AS VARCHAR(20)), 1, 11) AS CallDate,
SUBSTRING(CAST(calldate AS VARCHAR(20)), 12, 13) AS CallTime,
PhoneNumber, minutes, calldescription, charge
from voipcalls.dbo. fw_fnVOIPGetCustCallHistory('2549462784'
,
'08/01/2005', '09/21/2005', 0, -1)|||What is fw_fnVOIPGetCustCallHistory ? Can you give enough DDL and sample
data so that we can at least try to understand WHERE the conversion is
failing?
<lizansi@.gmail.com> wrote in message
news:1127404442.502836.42140@.g14g2000cwa.googlegroups.com...
> select SUBSTRING(CAST (calldate AS VARCHAR(20)), 1, 11) AS CallDate,
> SUBSTRING(CAST(calldate AS VARCHAR(20)), 12, 13) AS CallTime,
> PhoneNumber, minutes, calldescription, charge
> from voipcalls.dbo. fw_fnVOIPGetCustCallHistory('2549462784'
,
> '08/01/2005', '09/21/2005', 0, -1)
>|||fw_fnVOIPGetCustCallHistory is a function that returns a table with the
info of phone.
here's the function:
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
Function dbo.fw_fnVOIPGetCustCallHistory
(
@.PhoneNumber as VarChar(80),
@.StartDate DateTime,
@.EndDate DateTime,
@.Direction Int,
@.Billable Int
)
RETURNS @.CDR TABLE
(
uniqueid VarChar(32),
calldate DateTime,
PhoneNumber VarChar(80),
CallDescription Varchar(50),
Direction VarChar(20),
Minutes Int,
Charge Money,
Billable Bit
)
AS
Begin
Declare @.CDRWork TABLE
(
uniqueid VarChar(32),
calldate DateTime,
PhoneNumber VarChar(80),
L3 VarChar(3),
S42 VarChar(2),
S43 VarChar(3),
S44 VarChar(4),
CallDescription Varchar(50),
Direction VarChar(20),
Minutes Int,
BillRate Money Default 0,
Charge Money Default 0,
BillTypeID Int Default 0, --0=Non-Billable 1=PerMinute 2=PerCall
Billable Bit,
PhoneID Int,
Updated Bit Default 0
)
Set @.EndDate=DateAdd(d,1,@.EndDate)
If @.Direction in (-1,1)
Begin
Insert into @.CDRWork (uniqueid, PhoneNumber, Minutes, CallDate,
Direction)
select
uniqueid, dst as PhoneNumber, Ceiling(Cast(billsec as Decimal)/60)
as Minutes,
calldate, 'Outgoing' as Direction
from
cdr
Where
disposition='4' and billsec>0 and
src=@.PhoneNumber and
calldate>=@.StartDate and calldate<@.EndDate
End
If @.Direction in (-1,0)
Begin
Insert into @.CDRWork (uniqueid, PhoneNumber, Minutes, CallDate,
Direction, Charge, Billable)
select
uniqueid, src as PhoneNumber, Ceiling(Cast(billsec as Decimal)/60)
as Minutes,
calldate, 'Incoming' as Direction,
0 as Charge, 0 as Billable
from
cdr
Where
disposition='4' and billsec>0 and
dst=@.PhoneNumber and src<>@.PhoneNumber and
calldate>=@.StartDate and calldate<@.EndDate
End
---
Update @.CDRWork
Set
L3 =Left(PhoneNumber,3),
S42=Substring(PhoneNumber,4,2),
S43=Substring(PhoneNumber,4,3),
S44=Substring(PhoneNumber,4,4)
Where
Left(PhoneNumber,1)<>'1'
Update @.CDRWork
Set
L3 =Substring(PhoneNumber,2,3),
S42=Substring(PhoneNumber,5,2),
S43=Substring(PhoneNumber,5,3),
S44=Substring(PhoneNumber,5,4)
Where
Left(PhoneNumber,1)='1'
---
/*intl calls using 011 prefix and 2-digit country code*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 1
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.L3= '011' and
b.CountryCode=a.S42
---
/*intl calls using 011 prefix and 3-digit country code*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 1
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
a.L3= '011' and
b.CountryCode=a.S43
---
/*intl calls using 011 prefix and 4-digit country code*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 1
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
a.L3= '011' and
b.CountryCode=a.S44
---
/*normal domestic calls*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)+' '+b.State),
a.BillTypeID=
Case
When a.Direction='Outgoing' and b.Billable=1 Then 1
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
a.L3 = b.npa and
a.S43 = b.nxx and
b.nxx not in ('411', '555', '611')
---
/*intl calls like Canada or Caribbean using area codes*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 1
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
A.L3= b.npa and
b.billrate > 0 and
b.nxx is null
---
/*information calls (3-digit flavor)*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 2
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
A.L3= b.nxx and
b.nxx in ('411','555','611')
---
/*information calls (10-digit flavor)*/
Update a
Set
a.Updated=1,
a.PhoneID=b.PhoneID,
a.CallDescription=Upper(Rtrim(b.Display)),
a.BillTypeID=
Case
When a.Direction='Outgoing' Then 2
Else 0
End,
a.Billable=
Case
When a.Direction='Outgoing' Then b.Billable
Else 0
End
From
@.CDRWork a, fw_PhoneKey b
where
a.Updated=0 and
A.S43= b.nxx and
b.nxx in ('411','555', '611') and
a.L3 = b.npa
---
/*Calls not locatable in fw_PhoneKey*/
Update @.CDRWork
Set
CallDescription='UNKNOWN',
Charge=0,
BillTypeID=0,
Billable=0
Where
Updated=0
---
If @.Billable<>-1
Begin
Delete from @.CDRWork where Billable<>@.Billable
End
---
Update @.CDRWork set BillRate=dbo.fw_fnVOIPGetPhoneCallRate(PhoneID,
CallDate)
where Direction='Outgoing' and Billable=1
Update @.CDRWork set Charge=BillRate Where BillTypeID=2 --Per Call
Update @.CDRWork set Charge=Cast(Minutes as Money) * BillRate Where
BillTypeID=1 --Per Minute
---
Insert into @.CDR
(
uniqueid,
calldate,
PhoneNumber,
CallDescription,
Minutes,
Direction,
Charge,
Billable
)
Select
uniqueid,
calldate,
PhoneNumber,
CallDescription,
Minutes,
Direction,
Charge,
Billable
From @.CDRWork
Order By CallDate Desc
Return
End
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
When I run this sql query in query analyzer, it runs fine, gives me the
correct results. But when I call it from asp.net webpage, it faild.

Implicit conversion from datatype nvarchar to varbinary(MAX)

I am runnning SQL Server 2005...one of my columns is set to Varbinary(MAX), but when I try and set it to null, I get this error, when calling a stored procedure from C#.

'Implicit conversion from datatype nvarchar to varbinary(MAX) is not allowed. Use the CONVERT function to run this query.'

Thanks

Murph

are you sure you are passing null and not 'null' ?

take a look at this

--good
declare @.v Varbinary(MAX)
select @.v = null
select @.v
go


--bad, will fail
declare @.v Varbinary(MAX)
select @.v = 'null'
select @.v
go

Denis the SQL Menace
http://sqlservercode.blogspot.com/

|||I am trying to find out...I am using an ORMapper, and I am guessing it is doing something like you mentioned.|||

check your parameter datatype on your C# Code..