Showing posts with label content. Show all posts
Showing posts with label content. Show all posts

Sunday, March 11, 2012

Access to TEXT column

Hi,

I have a table with a TEXT column and this column contains an XML document. I'm developing a TSQL stored procedure which reads the content of this column and accesses the values in the XML elements but I have a lot of problems...

1) How can I read the text column and store the value in a variable? I tried

declare @.a varchar(2048)
set @.a = (SELECT TEXT_COLUMN FROM MY_TABLE)

but it returns

Server: Msg 279, Level 16, State 3, Line 2
The text, ntext, and image data types are invalid in this subquery or aggregate expression.

I tried also with the READTEXT function but I just can't find how to store data read in a variable...

2) which length should I use for the VARCHAR variable which will store the data? Is it possible not to specify a length with SQL Server 7 or 2000?

Thanks!

Andrea

In SQL Server 7/2000 local variables cannot have a text data type. My advice would be if you know the length of the xml data is not going to be greater than 4000 chars (aprox.), use an NVARCHAR, that is going to allow you to be more flexible with your code.

Hope this helps,

Roberto Hernández-Pou
http://community.rhpconsulting.net

|||

you can try this

declare @.a varchar(8000)

set @.a = (SELECT convert(varchar(8000),text1) FROM texttest where text1like'some%' )

select @.a

You 'll be able to use text column in procedures but it has to converted to an accepted datatype in procedures

|||Just keep in mind that a decent sized XML document can easily go past 8000 characters causing any extra data to be truncated.|||

Hi,

thanks Gopi, Roberto and Whitney! Useful answers and comments!

Andrea

Saturday, February 11, 2012

Access -export-> MS SQL 2005

how can i export all the content of an access database into a MS SQL 2005 database, with of course similar tables ?
thank youI don't know about SQL 2005 since I've never used it, but in SQL 2000 you can simply import an Access database in its entirety using a single DTS package. Does that help?|||ok i try !

thank you|||Another way would be to use the Upsizing Wizard within Access. You can find it in the 'Tools>Database Utilities' menu within Access.|||ok thank's a lot|||Hi Quentin

The upsizing wizard is a nice utility (and I would use it too) but remember to go through the migrated tables and check that the wizard has chosen the most appropriate (read correct) data types as there is not a simple 1 to 1 mapping from JET to SQL Server.

HTH|||i have to migrate t SQL in the next 2 weeks a big and full access database :-)

thanks to everyboy