Showing posts with label fails. Show all posts
Showing posts with label fails. Show all posts

Monday, March 19, 2012

Is this a bug with decimal(19,2)?

Seems like I've run across a place where INT works and MONEY works and DECIMAL(19,2) fails.

So, I have two questions:

* Should it work?

* Is there a better practice to handle optionally missing values, I'd rather have NULL than 0 anyway.

(there is also an xsd that shows the element as optional, but that seems to make no difference).

Apologies if this is kind of a newbie question (outside of the bug), me being an XML newbie.

Thanks.

Josh

Code Snippet

declare @.myxml XML

set @.myxml =

'<root>

<myrec>

<foo>123</foo>

<bar>123</bar>

</myrec>

<myrec>

<foo>234</foo>

</myrec>

</root>'

this works

select

t.rows.query('foo').value('.','int') as foo

from @.myxml.nodes('/root/myrec') as t(rows)

this works

select

t.rows.query('foo').value('.','int') as foo,

t.rows.query('bar').value('.','int') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

this works

select

t.rows.query('foo').value('.','money') as foo,

t.rows.query('bar').value('.','money') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

this fails

select

t.rows.query('foo').value('.','decimal(19,2)') as foo,

t.rows.query('bar').value('.','decimal(19,2)') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

/*

Msg 8114, Level 16, State 5, Line 27

Error converting data type nvarchar to numeric.

*/

Here is how you get a NULL with the value method and all three types (int, money, decimal) if the XPath expression does not find an element:

Code Snippet

declare @.myxml XML

set @.myxml =

'<root>

<myrec>

<foo>123</foo>

<bar>123</bar>

</myrec>

<myrec>

<foo>234</foo>

</myrec>

</root>'

this works

select

t.rows.value('foo[1]','int') as foo,

t.rows.value('bar[1]','int') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

this works

select

t.rows.value('foo[1]','money') as foo,

t.rows.value('bar[1]','money') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

this works

select

t.rows.value('foo[1]','decimal(19,2)') as foo,

t.rows.value('bar[1]','decimal(19,2)') as bar

from @.myxml.nodes('/root/myrec') as t(rows)

|||

Thanks.

Yes, I've seen that [1] syntax, and it seems to satisfy the value() function's demand for a singleton value, and then I don't need the separate query() method, ... but it seemed odd to me, didn't know how mainstream it was. Well, looks like it just got a lot more mainstream with me, thanks again!

Josh

Monday, March 12, 2012

Is there Limitations to Importing data to SQL Server Express

I have software that uses SQL Server Express as it's database. I am only able to import so many records until it stops and fails to allow me to import anymore.

I'm very new at this but, is there some type of limitation on Table size that's preventing me from importing anymore data?

I'd really appreciate it if someone could help me,

Thanks... Bill

Hi Bill,

SOL Server express is an evaluation copy. You need the full version. Please see this thread.........

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=157773&SiteID=1

|||

That is NOT correct -SQL Server Express is not JUST "an evaluation copy" SQL Server Express is a full featured product, albeit without some of the features included with the paid versions.

SQL Server Express is limited to a database size of 4GB; it could hold one table that held almost 4GB of data.

You may find importing data to be a bit easier using the DTSWizard. You 'should' be able to find a copy here: (assumes your SQL Server installation used [ Drive C: ].

C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTSWizard.exe

|||

Hi Arnie,

Thanks for updating that. I try, but I don't always have the correct answer.

|||

though it is a full featured free downloadable edition of sql server 2005, SQL Server express has few limitations. It can only have datbases of maximum 4 GB size. See whether u r database is exceeding this limit of not

Refer : http://www.microsoft.com/technet/prodtechnol/sql/2005/msde2sqlexpress.mspx

Madhu

|||

djartsinc,

Don't take it personally, one way you keep learning is to take the risk of exposing what you don't know. I learn something here almost every day. Some of my 'teachers' are gentle, some are a bit 'rough' -but my learning keeps on...

|||

djartsinc,

Thanks for responding. I know Express is a limited version, but I thought I could use it with the sofware I'm using it with. I can't afford $4,000 dollars. The software that is using Express for a database only cost $900.00. Do you see what I mean?

Thanks,

Bill

|||

Arnie,

Thanks... I'll look for the Wizard tonight. I've been importing records via the import feature of the software I'm using. I imported 265,000 records successfully, then after that it failed to import anymore. The records are.... FirstName, LastName, Address. and I have more to go.... the problem is ... I know the name of the database, but I'm not sure I would know the table to import the records into. I'm pretty new at this.

Thanks,

Bill

|||

Hi Arnie,

No offence taken. Learning is good. I learn something new everyday

|||

Hi Bill,

I understand, and your welcome.