I am using Jaydata with sqlite.
I am defining database and their tables using Jaydata.
I want to use datatype nvarchar(20) but it generates Jaydata error though it is a sqlite datatype.
Kindly,suggest me the way in which i can use varchar/nvarchar using Jaydata.
SQLite accepts a data type like nvarchar(20) but ignores most of it; the type is handled just as TEXT.
See the data type documentation.
Just use any text data type.
Related
I have a very simple data structure with an integer primary key and an "xml" column stored as ntext. How can I update specific nodes of the xml column stored as ntext?
The ntext data type is problematic to say the least.
As marc_s wrote in his comments, this type is deprecated, and even if it wasn't, it's the wrong data type to use for storing XML data.
The XML data type has been around since at least the 2012 version, and you should really consider changing your database structure to use it instead of the deprecated ntext.
If changing the database structure is impossible, then you will have to select the value, try to convert it into a usable type (since ntext doesn't even supports the replace function), manipulate the data, and then convert it back to ntext and update the row.
I want to write an access query to count the characters in an ntext field in a linked SQL server table.
In SQL server, I would just use this command (which wont work in access):
select datalength(nTextFieldName) //this command works on sql server but not in access
In access, I can only find the len command, which wont work on ntext fields:
select len(nTextFieldName) // access says nText is not a valid argument to this function.
Googling around, I've found a bunch of posts saying to use len, which is giving me an error.
What is the command?
ntext type doesn't work with LEN. This specific type as well as a few others are deprecated:
ntext, text, and image data types will be removed in a future version of Microsoft SQL
Server. Avoid using these data types in new development work, and plan to modify applications
that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. For more
information, see Using Large-Value Data Types.
The best way to handle this is to convert/cast the datatype to one that works such as varchar(max)/nvarchar(max) and only then get the LEN.
SELECT LEN(CAST(nTextFieldName As nvarchar(max)))
select LENGTH(nTextFieldName) from table_name;
Is there any reason why one would not use ntext and specifying no maximum length for all text entry fields?
One reason for not using ntext is that it will be removed from future versions of SQL Server.
http://msdn.microsoft.com/en-us/library/ms187993.aspx
You should use nvarchar(max) instead of ntext.
I would not use nvarchar(max) for all text fields. I like to have some control over what and how much gets stored. It is for instance a lot easier to build a client that needs to present the information if you know how much text is to be expected. Also users that wants to do bad things can fill a zip code field with all five books of the trilogy Hitch Hikers Guide to the Galaxy. Not that the books are bad but it should not be part of a zip code.
One reason is to do with how it's stored (although this depends on how much you store) and also partly do with restrictions on using some functions with 'text' type datatypes.
In addition, if you are worried about length, the nvarchar(max) is the recommended data type to use these days.
See here for more:
SQL Server Text type vs. varchar data type
http://geekswithblogs.net/johnsperfblog/archive/2008/04/16/ntext-vs-nvarcharmax-in-sql-2005.aspx
Another reason to add to this apart from it being a depreciated type is that ntext cannot be used as an operand to the UNION, INTERSECT or EXCEPT operators.
You will get the following error message
The data type ntext cannot be used as an operand to the UNION,
INTERSECT or EXCEPT operators because it is not comparable.
I suggest to stop using TEXT as it is obsolete and Cast it to NVARCHAR(MAX):
Reference
Can I use the SqlServer NTEXT data type in LightSwitch?
I know how to add extension business types, but they always subclass the existing LightSwitch base types. The LightSwitch base type 'String' maps to the SqlServer data type NVARCHAR which has a limit of 4000 characters (if I'm not mistaken).
I need more than 4000 characters!
Paul -- Nvarchar(4000) is what lightswitch defaults, but you can change the properties of the field by clearing the maximum length field, which will change it to nvarchar(max). Nvarchar(max) can store about 2Gb (much, much more than 4000 characters!)
Since NTEXT is deprecated, in order to use the proper data type (NVARCHAR(MAX)) in LightSwitch, create the table in SQL Server and then attach to it as an external table from LightSwitch. Reference.
I have a table that has ntext field. MSDN says that ntext is deprecated and they suggest other data types:
ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.
In my particular case it was decided to switch to varbinary(max). I tried to alter the table definition but that didn't work.
ALTER TABLE MyTable ALTER COLUMN MyColumn VARBINARY(MAX);
What are the possibilities to change the type to varbinary(max)? I tried change the type from ntext -> nvarchar(max) and then from nvarchar(max) -> varbinary(max) but that is not possible (error: Implicit conversion from data type nvarchar(max) to varbinary(max) is not allowed).
The only working solution is to add a new column of type varbinary(max), convert the existing value to the new column and then drop the old column. This takes WAY TOO MUCH time (on my dataset of about 15GB it takes about 30 minutes). That's why I am investigating other possibilities to achieve the same (possibly in-place = without moving data and conversion).
I presume you went with varbinary(max) because your ntext column had non textual data in it? In that case, I think you're going to have to add a separate varbinary(max) column to your table, then run a conversion operation to copy from the ntext to the new column. Then, delete the old column, and rename the new column to the old name.
"Implicit conversion from data type nvarchar(max) to varbinary(max) is not allowed" means that you're going to have to be explicit about the conversion.
It seems like this conversion is going to have to happen at some point. If you search, you'll find many people going from text to varchar(max) and stating it takes 20+ minutes to convert. My two cents after researching for a few minutes, so don't take it as gospel.
If your table just takes inserts, you could convert the existing data in a holding table and then rename the tables so the holding is then production. Then move any newly created data from the old table during your down time.
Handling updates makes things more complex of course.
Adding the extra column is probably the best way to go.
I favour doing this kind of thing in steps to reduce risks
Add the column varbinary(max) as nullable
Modify your insert code to populate both columns
At your leisure, say overnight, run the UPDATE statement with a CAST
Remove all code support for the old column, ensure new column is read
Drop the old column, and change the new column to be non null if needed