How To Deal With Nvarchar Column

Jan 19, 2008

Hi,

My company is starting to use nvarchar columns in our database products. We just found out that, suppose table T1 has a my_nvarchar_col column, and there is a row containing a unicode text say "some Chinese", if you want to select that row, you have to append "N" in front of the unicode constant in the "WHERE" clause. That is:


select * from T1
where my_nvarchar_col = N'some Chinese'

will return that row, while


select * from T1
where my_nvarchar_col = 'some Chinese'


will return NOTHING.

This brings us a huge problem - we have tens of thousands of such queries in our existing PowerBuilder code base. Do we have to go through all of them to add "N" to the "WHERE" clause? Is there a way we can set some attribute of SQL Server so that we do not need to do that?

Project stalled and I am under extreme pressure so please help ASAP!!

View 1 Replies


ADVERTISEMENT

Clustered Index On Nvarchar Column Or Int...

Jan 25, 2007

Users can approach their userprofile on my site using: www.mysite.com/name=peterName is a unique value within my database (db type: nvarchar(50))Now, I have created a clustered index on the username column.However, IMHO its faster to create a clustered index on the (also unique) usercode column since that is of type int.BUT since a user can approach my site based on username I feel that I HAVE to live with this setback in performance....Is that true or is there a better way to solve this issue?

View 1 Replies View Related

How To Add Newline In Column Of Type Nvarchar

Nov 7, 2005

Hi, I want to add a newline in a content of sql column (using t-sql and not asp.net textbox) so when content is being rendered in a .net textbox I get separate rows, so insteadcol1 col2 col3 I woule like to havecol1col2col3Thanks

View 3 Replies View Related

Need To Count And Rank NVARCHAR Column

Apr 2, 2008

Assuming that I have a table similar to this simplified version:

CREATE TABLE [SomeTable] ([Field1] NVARCHAR(50));

How could I count and rank the instances of specific values in the "field1" column? For example, let's say that I want to show the frequency of the column values like so:

field1 count
some value 24
another word 20
a value 5

(and so on...)

How can I do this?

- - - -
- Will -
- - - -
http://www.strohlsitedesign.com
http://blog.strohlsitedesign.com/
http://skins.strohlsitedesign.com/

View 3 Replies View Related

Asterisk In Nvarchar Column Type

Apr 1, 2014

Is it ok/possible to use and * in a column that is NVARCHAR type?

View 4 Replies View Related

Removing Spaces From An Nvarchar Column

Jul 20, 2005

Hello,This is a simple question, hopefully with a simple answer. I havean nvarchar column of length 255. In one of the rows I have thefollowing sentance - 'See the brown ball bounce'. Is it possible touse a command to remove all of the spaces in that sentance, so thatthe sentance reads 'Seethebrownballbounce'? As you can see, I am notjust interested in getting rid of the trailing and leading spaces.Thanks,Billy

View 1 Replies View Related

Modify A Column From Nvarchar(50) To A DateTime

Jun 3, 2007

Hello,

I have a column that is a currently set as nvarchar(50) and is called DateEmployed.
There are over a hundred rows that contain dates which is in nvarchar format.

This column now needs to be changed to a DateTime datatype. (Don't ask me it was not set
to a dateTime when this was first designed - I wasn't here)

However, I have to change this column to a DateTime without destroying the data.

Is there any easy way to write some script or use studio management to change this.

Currently the data is displayed like this in this column dd/MM/yyyy i.e. 25/8/2007.

The method I am using to try and change this is by going to studio management clicking
modify on the column and changing the datatype from a nvarchar(50) to a DateTime.

I get this following error message:
- Unable to modify table.
Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.

Any suggestions would be most grateful,

Thanks,

Steve

View 1 Replies View Related

T-SQL (SS2K8) :: How To Cast Source Column As Nvarchar

Jun 5, 2015

The source column is varchar(1) but i need this as nvarchar(1).. How can I cast this as NVARCHAR...

View 5 Replies View Related

Comparing Nvarchar(max) Column Using Like To Non-ASCII Range

Sep 25, 2006

Our database defines the long_value column as nvarchar(max). I want to find out which rows actually contain non-ASCII characters in that column, but this clause also returns rows with only ASCII characters:where long_value like (N'%[' + nchar(128) + N'-' + nchar(65535) + N']%')

What am I doing wrong?

View 5 Replies View Related

How Do I Insert A String Value With Quotes Into A Nvarchar Column

Jul 20, 2007

I am reading data from another data source and storing it in the sqlce database. Some of the string values I'm trying to insert into the database have single quotes in the string (i.e. Johnny's Company). When I try to insert the values with the single quotes, it throws an exception. The code I use to insert the records is as follows:



cmd.CommandText = "INSERT sy_company " +

" (company_id, company, co_name, companyid) " +

"VALUES(" +

"'" + dtSYCompany.Rows[x]["company_id"] + "'," +

"N'" + dtSYCompany.Rows[x]["company"] + "'," +

"N'" + dtSYCompany.Rows[x]["co_name"] + "'," +

"'" + dtSYCompany.Rows[x]["companyid"] + "')";

cmd.ExecuteNonQuery();



When the company name (co_name) has a single quote in it, I get the error. How do I write the insert statement so it will work even though the value being inserted into co_name has a single quote in it?



Thanks so much!

View 3 Replies View Related

Adding CRLF To Nvarchar(max) Column Text

Aug 31, 2007

A SqlServer 2005 db has a table with an nvarchar(max) column containing text with paragraph format. When displayed in a Windows form textbox each paragraph exhibits CRLF. When the table is opened in Management Studio the paragraph text is separated with two boxes at each CRLF.

I would like to insert an additional CRLF (or whatever is required) so that when viewed in a textbox each paragraph has a blank line separating it from the next paragraph. Much easier to read!!!

Can this be done? If so, how? Thanks in advance for any help you can provide.

View 11 Replies View Related

How Can I Save Big File To NVARCHAR(Max) Column In The Database?

Mar 28, 2007

helo..
I want to save file it size about 200MB to the database and after that

I want to get it from the database, the colmun type that i want to

save the file to it is NVARCHAR(Max).

I am using MS sql server 2005.

I was using this code to do this with Image Or Ntext column type but

it dose not working with NVARCHAR(Max) column?





Function SaveFileToDB(ByVal FileName As String, ByVal TblName As String, ByVal FldName As String, ByVal ColumnIDName As String, ByVal RowID As String) As Boolean

Try

Dim addEmp As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT @Pointer = TEXTPTR(" & FldName & ") FROM " & TblName & " WHERE " & ColumnIDName & " = '" & RowID & "'", MyConnection)

Dim trParm As SqlClient.SqlParameter = addEmp.Parameters.Add("@Pointer", SqlDbType.Binary, 16)

trParm.Direction = ParameterDirection.Output

addEmp.ExecuteNonQuery()

'''''''''''''''''''''''''''''''''''''

Dim bufferLen As Integer = 1048576

Dim appendToPhoto As SqlClient.SqlCommand = New SqlClient.SqlCommand("UPDATETEXT " & TblName & "." & FldName & " @Pointer @Offset 0 @Bytes", MyConnection)

Dim ptrParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Pointer", SqlDbType.Binary, 16)

ptrParm.Value = trParm.Value

Dim photoParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Bytes", SqlDbType.Image, bufferLen)

Dim offsetParm As SqlClient.SqlParameter = appendToPhoto.Parameters.Add("@Offset", SqlDbType.Int)

offsetParm.Value = 0

Dim fs As IO.FileStream = New IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read)

Dim br As IO.BinaryReader = New IO.BinaryReader(fs)

Dim buffer() As Byte = br.ReadBytes(bufferLen)

Dim offset_ctr As Long = 0

Do While buffer.Length > 0

photoParm.Value = buffer

appendToPhoto.ExecuteNonQuery()

offset_ctr += bufferLen

offsetParm.Value = offset_ctr

buffer = br.ReadBytes(bufferLen)

My.Application.DoEvents()

Loop

br.Close()

fs.Close()

Return True

Catch ex As Exception

MyErrStr = ex.Message

Return False

End Try

End Function





Public Function ReadFileFromDB(ByVal MyCommandText As String, ByVal FileColumnNumber As Integer, ByVal DSTFileName As String) As Boolean

Try

Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(MyCommandText, MyConnection)

Dim stream As IO.FileStream

Dim writer As IO.BinaryWriter

Dim bufferSize As Integer = 1048576

Dim outByte(bufferSize - 1) As Byte

Dim retval As Long

Dim startIndex As Long = 0

Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()

reader.Read()

stream = New IO.FileStream(DSTFileName, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)

writer = New IO.BinaryWriter(stream)

startIndex = 0

retval = reader.GetBytes(FileColumnNumber, startIndex, outByte, 0, bufferSize)

Do While retval = bufferSize

writer.Write(outByte)

writer.Flush()

startIndex += bufferSize

retval = reader.GetBytes(FileColumnNumber, startIndex, outByte, 0, bufferSize)

My.Application.DoEvents()

Loop

writer.Write(outByte, 0, retval - 1)

writer.Flush()

writer.Close()

stream.Close()

reader.Close()

Return True

Catch ex As Exception

MyErrStr = ex.Message

Return False

End Try

End Function


View 6 Replies View Related

Convert Column From NVARCHAR(MAX) To Money And Then Back Again.

Oct 8, 2007



I need to always have a formatting of 999,999,999.00 in a column called PropertyMap9.

PropertyMap9 is always a nvarchar(max)

How do I SET a value using a CONVERT or CAST to accomplish this ?

Why does this give me a syntax error ? The PropertyMap7 set actually works and performs the calculation and sets the new value for that row, however the next line gives an error. I need all 3 columns PropertyMap9, 8, and 7 to always have the above formatting, while still maintaining the nvarchar(max) datatype in the column. HELP!


update PropertyMapValues



set PropertyMap7 = CONVERT(NVARCHAR(MAX),CAST(PropertyMap8 AS money) - (CAST(PropertyMap9 AS money)),1)

set PropertyMap9 = CONVERT(NVARCHAR(MAX),CAST(PropertyMap9 AS money))

END



Msg 102, Level 15, State 1, Procedure UpdatePropertyMap7, Line 59

Incorrect syntax near '='.

View 1 Replies View Related

Nvarchar Column Text As Email Unicode Content

Feb 1, 2007

Hi,
i have a table with a nvarchar column,i want to send this column value as unicode content to customer mail box , but when i send it a mail with '?' customer receive , how can i accomplish this?
thanks

View 6 Replies View Related

Pass NVARCHAR (or Other String-type) Var As A Column Or Table Name In SQL

Jun 21, 2004

Hey folks, the question is fairly simple, unfortunately the answer has proven rather elusive.

Is it possible to declare a variable which would then be used to identify either a column or table in an SQL statement?

Here's a basic idea of what I'd like to do:

DECLARE @myVar AS NVARCHAR(50)

SELECT *
FROM @myVar

or

DECLARE @myVar AS NVARCHAR(50)

SELECT @myVar
FROM MyTable



I'm probably looking for some sort of built in function that will accept an argument here... like COLUMN(@myVar) or something of the like. I just don't know where to look...

View 1 Replies View Related

T-SQL (SS2K8) :: Remove Non-numeric Values From A Nvarchar Column

Dec 9, 2014

We have an address table with a house_num field which is a nvarchar.

Most of house numbers are numbers like 1234, 0989

But some of them have a letter behind it like 678 B, 8909 F, even some like this 123/B

We would like to remove any non-numeric letter for this column.

Is there a way to do it?

View 4 Replies View Related

Full-Text On HTML Stored In Nvarchar(MAX) Column

May 2, 2007

What is the best way of using the Full-Text feature on HTML?
I want to only search the text and omit the html tags.

If that involves storing as a different format, can someone tell me the best way of doing that?
I'm very new to sql and especially full-text.

Thanks.

View 1 Replies View Related

Analysis :: SSAS - Measure Creation On NVARCHAR Column?

May 26, 2015

I would like to know the possibility of creating Measure based on the below data.

I don't need to show any aggregate value. I need to show the value as it is.

View 6 Replies View Related

Storing A Carriage Return Or VbCrLf In An NVARCHAR Column

Sep 7, 2007

Is it possible to store a carriage return value or VbCrLf in an NVARCHAR column ?

I need to display a textbox in Reporting Services using one row, but showing multiple lines as a result of a few carriage returns.

View 3 Replies View Related

Problem With Converting The Nvarchar Value 'xxxxxID' To A Column Of Data Type Int.

Jan 23, 2007

Hi,
I have a webform with a drop-down listbox, binded to a table and a GridView, binded to another table. My goal is when I select a value (country in my case) in the drop-down listbox to change what is shown in the GridView, based on the ID that I get from the drop-down listbox.
Here is the code (the important parts...):
Select a Country : <asp:DropDownList ID="CountriesDropDownList" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="CountryID" Width="220px" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT [CountryID], [Name] FROM [DS_Country]">
</asp:SqlDataSource>
<asp:GridView ID="ProvincesGridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ProvinceID,CountryID,Name,ShortName,Description" DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" HorizontalAlign="Left" >
<Columns>
..............................
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DineSelectConnectionString %>"
DeleteCommand="DELETE FROM DS_Province WHERE ProvinceID=@ProvinceID"
SelectCommand="SELECT ProvinceID,CountryID,Name,ShortName,Description FROM DS_Province WHERE CountryID=@ddlCountryID"
UpdateCommand="UPDATE DS_Province SET CountryID=@CountryID,Name=@Name,ShortName=@ShortName,Description=@Description WHERE ProvinceID=@ddlCountryID"
InsertCommand="INSERT INTO DS_Province (CountryID,Name,ShortName,Description) VALUES (@CountryID,@Name,@ShortName,@Description)">
<SelectParameters>
<asp:ControlParameter Name="ddlCountryID" ControlID="CountriesDropDownList" PropertyName="DataValueField" />
</SelectParameters>
</asp:SqlDataSource>
 
When I run it I get this error "Syntax error converting the nvarchar value 'CountryID' to a column of data type int.". If I specify the Type="Int" in <asp:ControlParameter>..</> I get "Input string was not in a correct format. "
This is supposed to be easy, but I can't make it work ! Any suggestions will be more than welcome.
Thanks.

View 10 Replies View Related

SQL Server 2014 :: Converting Column Of Type Nvarchar To Datetime

Aug 19, 2015

I am trying to convert a column (nvarchar) to date time.

Here is an example of some values:

20110905
20110901
20111003

As expected, I received the following error: 'Conversion failed when converting date and/or time from character string.'

However, I am unsure how I should approach updating the whole column. I would like the format to be '103'.

View 9 Replies View Related

Problem With BULK INSERT ASCII File Into Nvarchar Column

Aug 21, 2007



Hi,
I have a problem with BULK INSERT. I created the following table:




Code Snippetcreate table Test
(id char(4), name nvarchar(16), last char(1))



I am trying to bulk insert data from ASCII (not unicode) file with only two rows:
0011First name
0018Second name



Since it is a fixed length file, I am using the following format file:




Code Snippet
8.0
3
1 SQLCHAR 0 4 "" 1 ID HEBREW_CI_AS
2 SQLCHAR 0 16 "" 2 NAME HEBREW_CI_AS
3 SQLCHAR 0 0 "
" 3 Last HEBREW_CI_AS





With bcp utility everything works just fine!



Code Snippet
bcp Demo.dbo.test in c: est -T -f c: est.fmt





But when I use BULK INSERT in the following form:



Code Snippet
BULK INSERT Test FROM 'c:Test'
WITH
(
FORMATFILE='c:Test.fmt',
CODEPAGE='OEM'
);



I am getting error
Server: Msg 4863, Level 16, State 1, Line 1
Bulk insert data conversion error (truncation) for row 1, column 2 (name).

Now, one interesting thing: if I change the name field from nvarchar to varchar, it is working with BULK INSERT as well.
Can anybody explain what is going on here?

I am using MS SQL 2000 and MSDE

Thanks in advance,
Eugene.

View 2 Replies View Related

The Conversion Of The Nvarchar Value '3008000003' Overflowed An Int Column. Maximum Integer Value Exceeded.

Jul 7, 2007

 HiAm Using ASP.NET With SQL SERVER 2005 Backend
AGENT CODE
3008000003

               



NAME
agent code dropdownlist values like 1005000006,2009000002,3008000003select dropdownlist value it display corresponding values related to that codewhen i select first 2 values its run properly,But when i select  3008000003 i will get following error messagein SQL SERVER 2005 Agent Code Date Type is "bigint"" The conversion of the nvarchar value '3008000003' overflowed an int
column. Maximum integer value exceeded. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.SqlClient.SqlException: The conversion of the nvarchar value
'3008000003' overflowed an int column. Maximum integer value
exceeded.Source Error:



An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:  Please Help me to solve this issueThanks With RegardsS.Senthil Nathan   

View 4 Replies View Related

SQL Server 2012 :: Sorting By Alphanumeric Table Column Of NVARCHAR Datatype

Sep 24, 2015

I am trying to sort my sql resultset by an alphanumeric column of a table which is of NVARCHAR datatype. The sample data is given below:

CREATE TABLE #Activities(activityName NVARCHAR(100))

INSERT INTO #Activities VALUES('Field phase S14-04932-01')
INSERT INTO #Activities VALUES('Phase reporting')
INSERT INTO #Activities VALUES('Phase running')
INSERT INTO #Activities VALUES('RD1')

[Code] ....

The output of the query is like this:

A1
A2
A3
A4
E1 0DAA1
E10
E2 0DAA2

[Code] .....

The output what I require is this:

A1
A2
A3
A4
E1 0DAA1
E2 0DAA2

[Code] ....

View 9 Replies View Related

How To Retreive Data From Nvarchar(max) Column, Using Com.microsoft.sqlserver.jdbc.SQLServerDriver?

Dec 31, 2007

I've looked through msdn and found an example, but it doesn't work. The problem is that when i use such construction

ResultSet rs1 = stmt.executeQuery("SELECT TOP 1 * FROM sys.check_constraints");
rs1.next();
Reader reader = rs1.getCharacterStream(17);

reader is set to null,but it mustn't be null cause i see some data through management studio in 17th column of sys.check_constraints table.

View 3 Replies View Related

Integration Services :: SSIS Lookup Not Working On Nvarchar Column Using FULL CACHE

Jul 30, 2015

I'm currently loading a package that does a lookup on a column of data type nvarchar(4).The values itself are (A+, A, B+, B, C, D, /). The strange lookup behaviour is happening for each of the cases, so it's not related to a specific value. After trying to put the cache on NO CACHE, the lookup works perfectly. When using the default FULL CACHE the strange behaviour happens. Could it be related to the data type? I have not yet tried to use a CHAR instead of a NVARCHAR but it looks like people have similar issues using CHAR.

View 2 Replies View Related

How To Sort Table In Sql2000 With Ipaddress(format X.x.x.x) As Column With Nvarchar Datatype In Ascending Order

Apr 19, 2006

How to sort table in sql2000 with ipaddress(format x.x.x.x) as column with nvarchar datatype in ascending order
without using stored procedure

Ex:

Table: netComputers(3 rows)
Column Name: ipAddress (string data type)

ipAddress
0.0.18.1
0.1.1.2
0.0.0.1

Sql query : if I use the query

Select ipAddress from netComputers order by cast( replace(ipaddress,'.','') as numeric(12)) asc

Gives result as :
ipAddress
0.0.0.1
0.1.1.2
0.0.18.1

Where as expected result should be:

ipAddress
0.0.0.1
0.0.18.1
0.1.1.2

View 18 Replies View Related

Query Fails When Returning A Single Record With Numeric Data In NVarChar(16) Column In Device App

Mar 12, 2008

If a Select is done on a column whose data type is nvarchar(16) and contains only numerals (UPC numbers) the select does not return the record.

1. Query with numerals in nvarchar column works as long as multiple records are returned (LIKE '012%')
2. Numeric (INT only one tested) columns works as expected
3. String columns with alpha data works as expected
4. Problem only exist when running in Device Emulator and/or actual device.
5. Same test on desktop app runs as expected.
6. Windows Mobile 6, Vista Ultimate
7. Same results when when connection to device from SSMS
8. SQL Servers comes on

Previous thread discussion of this problem (I thought that Parameters corrected problem, but not in all cases???)

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.sqlserver.ce&mid=0cd9cd3a-f9b0-477f-b1e7-c27eb76158ae

Here is the complete code:


SqlCeConnection _conn = null;

_conn = new SqlCeConnection(@"Data Source=program FilesTestResultSetevsoft.sdf;");

_conn.Open();


// DOES NOT WORK *** This statement does not return the record (it exist)

string _sql = "SELECT * FROM Product where RegDescr='0123456' ";




// works correctly

string _sql = "SELECT * FROM PRODUCT where ProdNum = 6523 ";


// works correctly *** as long as multiple records are returned

string _sql = "SELECT * FROM PRODUCT where RegDescr LIKE '01%' ";

// works correctly


string _sql = "SELECT * FROM PRODUCT where RegDescr='BACARDI SILVER RAZZ'";

SqlCeCommand _cmd = _conn.CreateCommand();

SqlCeDataReader _rdr;

_cmd.CommandText = _sql;

_cmd.CommandType = CommandType.Text;

// Same results using ExecuteResultSet or ExecuteReader

//_rdr = _cmd.ExecuteResultSet(ResultSetOptions.Scrollable | ResultSetOptions.Updatable);

_rdr = _cmd.ExecuteReader();



listBox1.Items.Add("In the while loop");

while (_rdr.Read())

{

listBox1.Items.Add(_rdr.GetValue(1) + " / " + _rdr.GetValue(3));

}

listBox1.Items.Add("Done");

View 1 Replies View Related

SQL 2005 Bug? Cannot Create Full Text Index For VARBINARY Column That's Populated With Converted NVARCHAR Values

Jul 11, 2007

Hi, I was wondering if any SQL Server gurus out there could help me...I have a table I'm trying to apply a full text catalog to, however no results are ever returned due to the text column being cataloged being of varbinary(max) that's being populated from a converted nvarchar(max) value - I've narrowed it down to this specifically, populating with non nvarchar text seems to work fine.To re-create the problem quickly...If I populate the column viaCONVERT(varbinary(max), 'test text')then there is no problem, I get results as expected.However if I populate the column viaCONVERT(varbinary(max), CAST('test text' as nvarchar(max)))no results are ever returned.Is this a bug with SQL Server 2005 Full Text Indexing? I'm happily creating full text catalogs when an nvarchar is not getting converted into a varbinary.I'm setting the Document Type column to '.html' (I've tried changing this to '.txt' in case it was a fault with the html ifilter but the problem persists so I believe I can rule this out).The reason I need to convert an nvarchar to varbinary is that the table holds multi-lingual text and I'm adding a html meta tag <META NAME="MS.LOCALE" CONTENT="ES"> to the beginning in order for the full text indexing word breaker to select the correct language to catalog the text with. The aim being to provide more relevant searches in users native languages (I've read a few articles that describe this technique, but it's the first time I've tried to apply it).Any pointers / suggestions would be greatly appreciated. Cheers,Gavin.

View 14 Replies View Related

SQL 2005 Bug? Cannot Create Full Text Index For Varbinary Column That's Populated From Converted Nvarchar Values

Jul 11, 2007

Hi, I was wondering if any SQL Server gurus out there could help me...

I have a table I'm trying to apply a full text catalog to, however no results are ever returned due to the text column being cataloged being of varbinary(max) that's being populated from a converted nvarchar(max) value.

To re-create the problem quickly...

If I populate the column via
CONVERT(varbinary(max), 'test text')
then there is no problem, I get results as expected.

However if I populate the column via
CONVERT(varbinary(max), CAST('test text' as nvarchar(max)))
no results are ever returned.

Is this a bug with SQL Server 2005 Full Text Indexing? I'm happily creating full text catalogs when an nvarchar is not getting converted into a varbinary.

I'm setting the Document Type column to '.html' (I've tried changing this to '.txt' in case it was a fault with the html ifilter but the problem persists so I believe I can rule this out).

The reason I need to convert an nvarchar to varbinary is that the table holds multi-lingual text and I'm adding a html meta tag <META NAME="MS.LOCALE" CONTENT="ES"> to the beginning in order for the full text indexing word breaker to select the correct language to catalog the text with. The aim being to provide more relevant searches in users native languages (I've read a few articles that describe this technique, but it's the first time I've tried to apply it).

Any pointers / suggestions would be greatly appreciated. Cheers,
Gavin.

UPDATE: Below is a T-SQL script you can run to demonstrate the effect I'm experiencing...




Code Snippet

-- Create test database
CREATE DATABASE FullTextTest
GO
USE FullTextTest
GO

-- Create test data table
CREATE TABLE TestTable
(
pk UNIQUEIDENTIFIER NOT NULL CONSTRAINT tablePK PRIMARY KEY,
varbinarycol VARBINARY(MAX),
documentExtension VARCHAR(5),
)
GO

-- The below single entry WILL BE FOUND (the text source is being entered directly)
INSERT INTO TestTable (pk, varbinarycol, documentExtension) VALUES (NEWID(), CONVERT(VARBINARY(MAX),'<META NAME="MS.LOCALE" CONTENT="EN">test entry 1'), '.html')

-- The bellow two entries below WILL NOT BE FOUND (the text source is taken from an NVARCHAR(MAX) value)
INSERT INTO TestTable (pk, varbinarycol, documentExtension) VALUES (NEWID(), CONVERT(VARBINARY(MAX), CAST('<META NAME="MS.LOCALE" CONTENT="EN">test entry 2' AS NVARCHAR(MAX))), '.html')
INSERT INTO TestTable (pk, varbinarycol, documentExtension) VALUES (NEWID(), CONVERT(VARBINARY(MAX), CAST('<META NAME="MS.LOCALE" CONTENT="EN">test entry 3' AS NVARCHAR(MAX))), '.html')
GO

-- Create the full text catalog
sp_fulltext_database 'enable'
GO
CREATE FULLTEXT CATALOG TEST AS DEFAULT
GO
CREATE FULLTEXT INDEX ON TestTable (varbinarycol TYPE COLUMN documentExtension LANGUAGE 1033)
KEY INDEX tablePK
GO

-- NOTE: You might need to give the catalog a chance to build before running the script below.

-- Now do a search that SHOULD RETURN 3 ROWS of data, but ONLY 1 ROW IS RETURNED
SELECT CAST(varbinarycol AS NVARCHAR(MAX)) FROM TestTable WHERE CONTAINS(varbinarycol, 'test')

View 10 Replies View Related

Done Deal

Dec 7, 2007

It's because of this one or maybe more people that the whole world of the internet becomes so much of crappy messy place... *sighs*

Since there is really no specifics on deleting a topic, this is the best I could do.

View 7 Replies View Related

The Parameterized Query '(@contactdate Nvarchar(4000),@dnbnumber Nvarchar(4000),@prospect' Expects The Parameter '@futureopportunity', Which Was Not Supplied.

Jan 10, 2008

HI, I am running the below method which returns this error: The parameterized query '(@contactdate nvarchar(4000),@dnbnumber nvarchar(4000),@prospect' expects the parameter '@futureopportunity', which was not supplied" Please help.Private Shared Sub InsertData(ByVal sourceTable As System.Data.DataTable, ByVal destConnection As SqlConnection)
' old method: Lots of INSERT statements Dim rowscopied As Integer = 0
' first, create the insert command that we will call over and over:
destConnection.Open()Using ins As New SqlCommand("INSERT INTO [tblAppointmentDisposition] ([contactdate], [dnbnumber], [prospectname], [businessofficer], [phonemeeting], [followupcalldate2], [phonemeetingappt], [followupcalldate3], [appointmentdate], [appointmentlocation], [appointmentkept], [applicationgenerated], [applicationgenerated2], [applicationgenerated3], [comments], [newaccount], [futureopportunity]) VALUES (@contactdate, @dnbnumber, @prospectname, @businessofficer, @phonemeeting, @followupcalldate2, @phonemeetingappt, @followupcalldate3, @appointmentdate, @appointmentlocation, @appointmentkept, @applicationgenerated, @applicationgenerated2, @applicationgenerated3, @comments, @newaccount, @futureopportunity)", destConnection)
ins.CommandType = CommandType.Textins.Parameters.Add("@contactdate", SqlDbType.NVarChar)
ins.Parameters.Add("@dnbnumber", SqlDbType.NVarChar)ins.Parameters.Add("@prospectname", SqlDbType.Text)
ins.Parameters.Add("@businessofficer", SqlDbType.NChar)ins.Parameters.Add("@phonemeeting", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate2", SqlDbType.NVarChar)ins.Parameters.Add("@phonemeetingappt", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate3", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentdate", SqlDbType.NVarChar)
ins.Parameters.Add("@appointmentlocation", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentkept", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated", SqlDbType.NVarChar)ins.Parameters.Add("@applicationgenerated2", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated3", SqlDbType.NVarChar)ins.Parameters.Add("@comments", SqlDbType.Text)
ins.Parameters.Add("@newaccount", SqlDbType.NVarChar)ins.Parameters.Add("@futureopportunity", SqlDbType.NVarChar)
' and now, do the work: For Each r As DataRow In sourceTable.RowsFor i As Integer = 0 To 15
ins.Parameters(i).Value = r(i)
Next
ins.ExecuteNonQuery()
'If System.Threading.Interlocked.Increment(rowscopied) Mod 10000 = 0 Then
'Console.WriteLine("-- copied {0} rows.", rowscopied)
'End If
Next
End Using
destConnection.Close()
End Sub

View 6 Replies View Related

How Do I Deal With Comma's In SQL Queries

Feb 5, 2008

 How can I search for all the O'Connor's in my SQL Server database?eg: SELECT [Surname]  ,[FirstName]  FROM [myDB].[dbo].[Names]  WHERE ([Surname] = 'O'Connor')  

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved