Excel Transformation Adding Single Quote To Beginning Of Strings
Jun 28, 2007
I have a ssis package created in VS2005 that transforms a SQL query result into an excel spreadsheet. The DataFlow uses a DataReaderSource to query the data and an ExcelDestination to transform the data. The problem is that in the resulting spreadsheet any columns containing string data have a single quote inserted in front of the data. So a string like [My data] becomes ['My data]. When I preview it in the Excel Destination Editor it looks right (without the single quote). What is happening here, is it a bug or does something need to be configured. I checked all the properties that I could find. This is working nice, if I could only overcome this problem.
I'm having trouble importing a CSV file into SQL using SSIS. The trouble seems to stem from truncation and from quote encapsulated fields.
Firstly it's worth noting that some of the data within the quotes contains the separator. E.g.
12,"some text, and a comma",34
Thankfully SSIS seems to cope with that by specifying " as the Text Qualifier. My next problem was that the SSIS Import and Export Wizard gave an error: "failed because truncation occurred". But I fixed this by specifying the OutputColumnWidth for the NCHAR and NVARCHAR type columns to be the width from the table definition.
But now I have another problem with the length of fields. Consider the following where the center column is NCHAR (22)
101,"some text, and a comma",303 102,"some ""quoted text"" bye",303
The first row has the correct width (once the encapsulating quotes are stripped out), but the second row does not, because it seems that when I exported the table the export wizard escaped the quote characters within encapsulated strings using quote characters. So I am back to getting the "truncation occurred" error. How can I get around this within SSIS?
is there some way to avoid single quote for all fields (including text) in excel when we export data from sql server? i dont want to have any single quote in excel when i export data.
Some of my records starts with a double quote, when I do a search for all records starting with A I can get all except the ones that start "A fine day ...
I ran a large query and exported it to xls. In Excel, I noticed a value of '2.00E+01'. I formatted the Excel cell and then got a value of '20'. I searched for the record in SQL Server 2008, ya I know, ancient. The value is '2E1' which excel is seeing as scientific notation.
Can I use a case statement that when an 'E' is present to add a single prefix quote like '2E1? Or perhaps do it for the whole column? Or put put double quotes around the whole field?
How do I insert a single quote ' into a table? For example:Insert mytable values (1,''')I get an error message.Any ideas? The server does not recognize double quote (why? is thistsql, ansi?), otherwise I could have written it as:Insert mytable values (1,"'")Thanks.
I am using SQL Server 2005, I have a NVarChar parameter called @Text that I use to build a dynamic Where clause for my SELECT Statement. SET @l_Where = @l_Where + N' AND (StatusDesc LIKE ''' + Replace(@Text, "'", "''") + N'%'')' This gives me an invalid column error. How do I replace the single quotes in @Text with 2 Single Quotes? TIA,Jason
I have 2 SQL 6.5 databases on separate servers. Server A replicates a text field into a table on server B.
On server A the field contains text similar to THIS IS FRED'S HOUSE. After replication to Server B it looks like THIS IS FRED''S HOUSE. The distribution database also has it as THIS IS FRED''S HOUSE. Using ODBC trace I cannot see the value being passed in the text field as it is displayed as a question mark e.g. ?.
only difference is the machine name has a single quote (apostrophy) in the name... xyz's
Now - a portion of the application is failing - the starting of the application runs ok, and the system is indeed seeing the database (it allowed the user to log in) so the connection string seems to be ok - just in that one part...
does anyone know if the machine name with an embedded apostrophy will cause the ADO connection string to puke???
i am trying to add a single quote to a string. This is a must because i am making a full select statement in which i need the single quote to compare values. Obviously this breaks my string invalidating my query.
ej:
SELECT avg(tabla.ip_trend_value) as valor, FLOOR(Cast(tabla.ip_trend_time AS FLOAT)) as tiempo FROM TESTLAB5.dbo.CE02_L21_916AI31_43 tabla, TESTLAB5.dbo.CE02_L21_916XI31_4 t2 WHERE t2.ip_trend_value = 'Alimentacion Digestores' and t2.ip_trend_time = tabla.ip_trend_time group by FLOOR(Cast(tabla.ip_trend_time AS FLOAT))
and this will become something like this.
SELECT @TableName = 'TESTLAB5.dbo.'+@TableName SELECT @SQL = 'SELECT avg(tabla.ip_trend_value), FLOOR(Cast(tabla.ip_trend_time AS FLOAT)) FROM ' SELECT @SQL = @SQL + @TableName SELECT @SQL = @SQL + ' tabla, TESTLAB5.dbo.CE02_L21_916XI31_4 t2' SELECT @SQL = @SQL + ' WHERE t2.ip_trend_value = '@NombreVar'and t2.ip_trend_time = tabla.ip_trend_time' SELECT @SQL = @SQL + ' group by FLOOR(Cast(ip_trend_time AS FLOAT))'
the @NombreVar is the equivalence of 'Alimentacion Digestores'.
is there something i can add or change to make it work ?
I have a problem with one of my apps. The apps was written long long time ago in C++ and uses SQL server 7
The problem is that when the users key in some data with single quote in it the query failed, obviously. Is there any way that SQL Server automaticaly manages this kind of Insert/Update statements ?
I'm inserting a row of people's names and addresses to a table. This seems to work great, unless the person has ' in their name, for example O' Riordan. When the address has single quote (such as Wilder's Path), I'd get the same error, unclosed quote when inserting the row.
What would be the best way to work around this, other than read the line and replace it with a space.
HI,I anm geting error when i want to store some text which contens single quote like this Hi I am 'santosh'.as i am using text editor which genetates XML data (not pure) so i have used varchar(max) to store the data but it gives error. Is thier any way to store text with single quote........ urgent plz.
Hi, I am beginer to ASP.NET. I want to insert ' ( single quote ) which is entered by the user in a textbox of the ASP.NET web page. As you all know in the insert command the column is ending at that single quote.
How do I get a single quote (') in a NVARCHAR string in MS SQL Server?e.g. SELECT @strsql = "SELECT * FROM tblTest WHERE Field1 Like 'blah''Obviously this is invalid as the single quote before "blah" would end thevarchar string.How do I get round this?
I'm cleaning up a column in my table and getting rid of special characters.The only think I can't get rid of with the REPLACE function is single quotes.I'm doing aUPDATE TableSET Column = REPLACE(Column,'''','') --that's four single quotes then two single quotesBut the single quotes in my column wouldn't go away.I know that
Hi all, I have never used SSIS before, but am looking to use it in this aspect:
1) A user uploads an Excel file into Sharepoint. This will be through a Document Library in a Sharepoint page.
2) When this file is uploaded, I'd like SSIS to notice there is a new file and process it - it will pull information from the Excel file, put it into a database, and - if this is possible - delete the new file.
3) This is iffy. Can SSIS then generate an InfoPath document from the information stored in the database? If not, I can just have a InfoPath query form.
I'd just like to know if this is possible. If you have any helpful links, please let me know - I would greatly appreciate it!
hellohow are you all ?I want to insert ,select update date in database these data contains special chars like ' & _ <> and so onso is there any way to handle this issue ? please help methanks a lot
We have a .NET drop down, which gets populated as the user types in letters(last name). If the user types in the single quote we get the error about not escaping the single quote. Question is, which way would it be easier to fix, in the .NET code or in the SQL procedure? I am not to sure if we have full access to the source code since that is a 3rd party control, so if that is not feasible how would I fix that in the stored procedure? This is the current proc that we are using:
Code Snippet select @str = 'SELECT DISTINCT TOP ' + @Top + ' e.DisplayName as DbComboText, e.EmployeeID as DbComboValue FROM DepartmentDirectory.dbo.Employees ee INNER JOIN DataMart.dbo.Employees e ON ee.UIN = e.UIN WHERE e.LastName like ''' + @LastName + ''' AND e.FirstName like ''' + @FirstName + ''' ORDER BY e.DisplayName'
my asp.net application communicate with SQL database, but when I have single quote ( ' ) in my string then it throws error. and it does not insert that string in database. How can I solve this problem . or give me some suggestions on this issue. thank you maxmax
I can think of ways to resolve this issue, but I am wondering if there is a standard practice or some setting that is used to ensure that text containing a single quote, such as "Bob's house", is passed correctly to the database when using a SqlDataSource with all of the default behavior. For example, I have a FormView setup with some text fields and a SqlDataSource that is used to do the insert. There is no code in the form currently. It works fine unless I put in text with a single quote, which of course messes up the insert or update. What is the best way to deal with this? Thank you
How can i convert single quote i.e. ' using replace method. Is there any methods we have to replace or to convert single quotation . Please let me know.
I've a weird problem in my application. In of the pages, while trying to update the text box "Name", when I enter Linda's test, it gets saved as Linda''s test. I'm not sure if this is a problem due to SQL server. When I look at the stored procedure, I don't anything different. Also, when I update the table directly in SQL Server, the result is displayed in single quote. But if I update the field thro' the application, the returned name is with double quotes instead of single quote. Has any of you faced problems like this? What am I missing? What do I need to do to get the name saved the way I entered (with single quotes) instead of double quotes?
Hi: Got a newbie question that's been giving me fits! Basically I'm replicating what's going on here on this board...creating a "posting" interface that takes the "message" and inserts it into a table using an ADODB connection (using INSERT INTO table name,tablecells and VALUES)
However, if someone types in a single or double quote in the body of the message, I get an error similar to this:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 's'.
/test.asp, line 29
I think I understand why it's happening (SQL is interpreting the quote mark as a string-end), but what am I supposed to do to get around it?
I have a very complex (for me, anyway) data transformation problem.
I've been given a flat-file of physician data from another system which must be automated for entry into the SQL server on a regular basis.
This was no problem until we discovered that several fields (all of which we wanted to use) had multiple pieces of information in them, separated by semicolons.
Well, this didn't seem to be too big of a problem, so I wrote a DTS activeX script to handle it. This is what I originally wrote:
'******************* Function Transform() 'Declare variables Dim strOffice Dim strOfficeNew Dim cChar Dim x Dim y Dim z
'Scrub values into new rows strOffice = DTSSource("Col050") x = 1 y = len(strOffice) z = 1
While x <= y cChar = Mid(strOffice, x 1) If cChar <> ";" Then strOfficeNew = strOfficeNew & cChar Else DTSDestination("Phys_No") = DTSSource("Col001") DTSDestination("Addr_No") = z DTSDestination("Addr_Office") = strOfficeNew strOfficeNew = "" z = z + 1 End If x = x + 1 Wend
'Insert final record after last semicolon If strOffice <> "" Then DTSDestination("Phys_No") = DTSSource("Col001") DTSDestination("Addr_No") = z DTSDestination("Addr_Office") = strOfficeNew End If
Transform = DTSTransformStat_OK End Function '*********************
This, of course, didn't work. WHat I got was the last part of the parsed data, which for the first record, was the second Address in the field.
I searched around, and found the following script that is supposed to allow multiple rows off of a single row, but I can't seem to merge the two and still get the data out clean.
'********** Dim nCounter nCounter = 4
Function Main()
if nCounter > 0 then Main = DTSTransformStat_SkipFetch DTSDestination("PatientNumber") = DTSSource("PatientNumber") Select Case nCounter Case 1 DTSDestination("PhysicianType") = "Admitting" DTSDestination("PhysicianId") = DTSSource ("AdmittingPhysician") Case 2 DTSDestination("PhysicianType") = "Attending" DTSDestination("PhysicianId") = DTSSource ("AttendingPhysician") Case 3 DTSDestination("PhysicianType") = "Referring" DTSDestination("PhysicianId") = DTSSource ("ReferringPhysician") Case 4 DTSDestination("PhysicianType") = "Consulting" DTSDestination("PhysicianId") = DTSSource ("ConsultingPhysician") End Select nCounter = nCounter - 1 else nCounter = 4 Main = DTSTransformStat_SkipInsert end if End Function '**************
I'm not a VB Script expert, so there's probably something very simple that I'm missing here... if someone could point it out, I'd be greatly appreciative.