Converting query to SP; ListQualify is breaking string for SQL
Hello, all.
I'm attempting to convert a number of queries into SPs; for the most part, it's going smoothly.
However, there is one query (quite large) that I am having problems converting to SP because the query is using ListQualify to insert apostrophes around each list element, and it's breaking the string being sent.
How can I keep the apostrophes without breaking the SQL string?
Thanks,
^_^
Just escape the apostrophe with another apostrophe? OR, do you mean surround the apostrophe with quotes? (" ' ")
Thanks,
^_^
Similar Messages
-
How to encode sql string for SQL Server when using JDBC?
in code, dynamically generate sql stirng like:
String sqlstring = "select column from table where column=' " + var + " ' ";
Question is: if var include char ' , it will cause error becuase ' is reserved by SQL Server for string reference.
So how to encode string for dynamic sql string? for example, following sql(when var =" I'm tester"):
select column from table where column like ' I'm tester '
Edited by: KentZhou on Jun 17, 2009 3:10 PMUse PreparedStatement. Use it all the way. It not only saves you from SQL injections, but also eases setting non-standard Java objects like Date and InputStream in a SQL statement.
Prepare here: [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html]. -
Convert Data type from Oracle Data time string to SQL Date time data type
I have a time stamp column pulled from oracle into a SQL server db table varchar datatype column.
Now i want to change that column to date time.
Following is the data present in the table:
01-APR-11 02.15.00.026000 AM -08:00
01-APR-11 04.15.00.399000 AM -08:00
01-APR-11 06.15.00.039000 AM -08:00
I want to convert this data into sql server datetime data type.
Please advice.
Thanks,
Sam.
I am unable to find the solution in other sites which is why I have posted it in Oracle forum for seeking solution.
Thanks in Advance.
Sam.Sam,
How are you actually loading the data into SQL*Server - are you using something like an Oracle gateway, BCP or another Microsoft utility of some sort ?
If you are using an Oracle problem then we may be able to help but if using a Microsoft utility then you should really follow up with Microsoft to know what format the data should be in to use a Microsoft utility.
Regards,
Mike -
Convert query made u200Bu200Bin SQ01, SQ02 and SQ03 for a transaction set
Hello people, how do I create a transaction for a report I did in queries with the transaction SQ01, SQ02 and SQ03? ...
hugsHi Stelio Mucavele
i had the same issue resolved by below steps
1>go to SQVI t code and enter your query name and press enter
2>In the menu path select Quick view--> additional functions-->Generate Program
3>After Generating the program In the menu path select Quick view--> additional functions-->Display report Name
4>Now in se38 enter the report name in Program field and execute
5>You will get the Initial Selection screen of the report . Go to Menu of System -->Status
6> Note down the Program name and Screen number
7>Go to SE93 and Create a Z tcode for the query, Enter the description and importantly you have to select the 2nd Option radio Button Program and Selection Screen (Report Transaction) and Press enter
8>In the next screen enter the Report name In Program field and enter the screen number
9>In the classification Section select Professional user Transaction
10>In GUI support section select all the options i.e SAPGUI for HTML,Java,Windows
and save
the system will ask for Package select your package if not there then select local object
now execute the Z tcode your report will run sucessfully
Regards
Vijay hebbal -
Is it needed to convert the values frm text field to numeric for sql server
hi all,
i'm using tomvat4.0,back end sql server 200.
when i insert the values in to the table it is giving an exception sayin "Error in converting varchar to numeric"
is it necessary to convert those strings from text fields into int before passing them to the sql query..
i think it is not necessary for oracle..but not sure with sql server..
pls help me
cheers
chanduyap, every thing is fine...
n i got the solution...when the text field is left blank....the requst.getParameter returns [coe]""(null)
wen the database is lookin for a numeric it is giving null...which is not acceptable...
so inserted this code...
if(request.getParameter("...").equals("")) {
//assign zero to a variable then insert that variable....
}thanx for the responses
cheers
May the solutions to one's problem pop up in one's mind itself
chandu -
SQL 2000 ODBC CONNECTION STRING FOR SQL 2008
i have vb 6 application. Database is SQL server 2000.
my connection string is (using odbc driver),
.ConnectionString = "Driver={SQL Server};SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
Now i have tried this application with SQL server express 2008 R2
Can i still keep the old connection string? will there be any problem in future?
(if i have to change then have to change at so many places.....)
I can run application without any problem for now (not changed connection string to new one)
otherwise i have to use ODBC or OLEDB which are,
.ConnectionString = "Driver={SQL Server Native Client 10.0};SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
or
.ConnectionString = "Provider=SQLNCLI10;SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
if i have to change to new connection string Which one is better to use odbc or oledb.
h2007personally I favor ODBC as it is easy to use sometime. Additionally you can check the link below:
http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/19e0c306-0be4-46b5-b207-0937931d63a7
cheers!!!
Vatsa
www.objectiveprogramming.com -
Connection Strings for SQL Server 2012
I have installed SQL Server 2012 on my machine.
I did not install a user_id or password.
I have a working website with "Remote Access" Role installed.
I have tried many different connection strings from
http://www.connectionstrings.com/sql-server-2012/:
This stood out:
Server=(localdb)\v11.0;Integrated Security=True;AttachDbFileName=C:\inetpub\wwwroot\App_Data\db.mdf;Trusted_Connection=True;
Error Code:
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.I would recommend asking them in SQL forums: https://social.technet.microsoft.com/Forums/en-us/home?forum=sqlgetstarted&filter=alltypes&sort=lastpostdesc
This posting is provided AS IS with no warranties or guarantees , and confers no rights.
Ahmed MALEK
My Website Link
My Linkedin Profile
My MVP Profile -
Installed Azure VM From gallary with Sql Server 2012, even after allowing 1433 port through firewall, still cant get access to Sql Server from outside vm, So please provide steps for getting exact ServerName for connecting Sql Server on VM for connecting
from Visual Studio Application.
Thanks.Hi,
You can check the DNS name of the VM in the VM instance page of the Azure management portal.
In addition, you can also refer to the third-party article below:
http://thomaslarock.com/2014/02/connect-to-a-windows-azure-vm-using-sql-server-management-studio/
( Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please
make sure that you completely understand the risk before retrieving any suggestions from the above link.)
Best regards,
Susie
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
I have a table-valued function that run in sql 2005 and when try to execute in sql 2008 r2, return the next "Conversion failed when converting date and/or time from character string".
USE [Runtime]
GO
/****** Object: UserDefinedFunction [dbo].[f_Pinto_Graf_P_Opt] Script Date: 06/11/2013 08:47:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[f_Pinto_Graf_P_Opt] (@fechaInicio datetime, @fechaFin datetime)
-- Declaramos la tabla "@Produc_Opt" que será devuelta por la funcion
RETURNS @Produc_Opt table ( Hora datetime,NSACOS int, NSACOS_opt int)
AS
BEGIN
-- Crea el Cursor
DECLARE cursorHora CURSOR
READ_ONLY
FOR SELECT DateTime, Value FROM f_PP_Graficas ('Pinto_CON_SACOS',@fechaInicio, @fechaFin,'Pinto_PRODUCTO')
-- Declaracion de variables locales
DECLARE @produc_opt_hora int
DECLARE @produc_opt_parc int
DECLARE @nsacos int
DECLARE @time_parc datetime
-- Inicializamos VARIABLES
SET @produc_opt_hora = (SELECT * FROM f_Valor (@fechaFin,'Pinto_PRODUC_OPT'))
-- Abre y se crea el conjunto del cursor
OPEN cursorHora
-- Comenzamos los calculos
FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
/************ BUCLE WHILE QUE SE VA A MOVER A TRAVES DEL CURSOR ************/
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status = -2)
BEGIN
-- Terminamos la ejecucion
BREAK
END
-- REALIZAMOS CÁLCULOS
SET @produc_opt_parc = (SELECT dbo.f_P_Opt_Parc (@fechaInicio,@time_parc,@produc_opt_hora))
-- INSERTAMOS VALORES EN LA TABLA
INSERT @Produc_Opt VALUES (@time_parc,@nsacos, @produc_opt_parc)
-- Avanzamos el cursor
FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
END
/************ FIN DEL BUCLE QUE SE MUEVE A TRAVES DEL CURSOR ***************/
-- Cerramos el cursor
CLOSE cursorHora
-- Liberamos los cursores
DEALLOCATE cursorHora
RETURN
ENDYou can search the forums for that error message and find previous discussions - they all boil down to the same problem. Somewhere in your query that calls this function, the code invoked implicitly converts from string to date/datetime. In general,
this works in any version of sql server if the runtime settings are correct for the format of the string data. The fact that it works in one server and not in another server suggests that the query executes with different settings - and I'll assume for
the moment that the format of the data involved in this conversion is consistent within the database/resultset and consistent between the 2 servers.
I suggest you read Tibor's guide to the datetime datatype (via the link to his site below) first - then go find the actual code that performs this conversion. It may not be in the function you posted, since that function also executes other functions.
You also did not post the query that calls this function, so this function may not, in fact, be the source of the problem at all.
Tibor's site -
SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string. 'Received Alerts' (OAIB)
SELECT
CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
WHEN T0.DocStatus = 'C' THEN 'CLOSED' END AS 'Document Status',
T0.DocDate AS 'Posting Date',
T0.DocNum AS 'Doc.No',
T0.NumAtCard,
T0.TransId AS 'Trans. No.',
T0.Comments AS 'Remarks',
T0.CardCode AS 'Offset Acct',
T0.CardName AS 'Offset Acct Name',
sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
T3.DueDate AS 'Cheque Date',
T3.CheckSum AS 'Amount'
FROM ODPO AS T0 LEFT OUTER JOIN
VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
VPM1 AS T3 ON T2.DocEntry = T3.DocNum
where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'Hi,
Try this:
SELECT
CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
WHEN T0.DocStatus = 'C' THEN 'CLOSED' END AS 'Document Status',
T0.DocDate AS 'Posting Date',
T0.DocNum AS 'Doc.No',
T0.NumAtCard,
T0.TransId AS 'Trans. No.',
T0.Comments AS 'Remarks',
T0.CardCode AS 'Offset Acct',
T0.CardName AS 'Offset Acct Name',
sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
T3.DueDate AS 'Cheque Date',
T3.CheckSum AS 'Amount'
FROM ODPO T0 LEFT OUTER JOIN
VPM2 T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
LEFT OUTER JOIN
OVPM T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
VPM1 T3 ON T2.DocEntry = T3.DocNum
where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
group by T0.DocStatus,T0.DocDate ,
T0.DocNum ,
T0.NumAtCard,
T0.TransId ,
T0.Comments ,
T0.CardCode,
T0.CardName ,
T0.WTSum ,
T3.DueDate ,
T3.CheckSum
Thanks & Regards,
Nagarajan -
Conversion failed when converting date and/or time from character string
Hi experts,
I'm trying running a query in Microsoft Query but it gives the following error message:
"conversion failed when converting date and/or time from character string"
when asks me the data I'm inserting 31-01-2014
i've copy the query form the forum:
SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
CASE WHEN T0.TransType=13 THEN 'Invoice'
WHEN T0.TransType=14 THEN 'Credit Note'
WHEN T0.TransType=30 THEN 'Journal'
WHEN T0.TransType=24 THEN 'Receipt'
END AS 'Document Type',
T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
ORDER BY T1.CardCode, T0.DueDate, T0.Ref1Hi,
The above error appears due to date format is differnt from SAP query generator and SQL server.
So you need convert all date in above query to SQL server required format.
Try to convert..let me know if not possible.
Thanks & Regards,
Nagarajan -
Convert data link between one query's group and another querys group to SQL
Hi
I have a report where there are 2 query Groups. These 2 query groups r linked by data link. How do i combine these queries to One query so i can use it as a SQL query.
ThanksHi,
Assume that we have two queries Q1 and Q2 and the common column between the two queries is "comn".
Now we can convert the datalink into SQL as follows:-
SELECT *
FROM
(Query for Q1)a,
(Query for Q2)b
WHERE a.comn=b.comn(+)
Note: "a" and "b" are alias names for Q1 and Q2. -
Needing to convert a local "numeric" value to a string type using the expression browser.
I am trying to convert a "numeric" local value to a string through the expression browser in order to supply a string arguement. I am currently looking through the expression browser options, but I can not find any type of Number "ToString()" function.
Solved!
Go to Solution.Hi,
Str() function
ie
locals.tostring = Str(locals.dec_value)
Regards
Ray Farmer -
Save Query - An error occurred while creating connection strings for the query
A workbook trying to edit and reload I get the following error "Save Query - An error occurred while creating connection strings for the query" No Power Pivot data model or anything.
I am getting the same error when editing a Power Query in an Excel spreadsheet. It happens when I change a Group By step to do a Sum instead of Count Rows.
-
PLS CONVERT QUERY- UPDATE to MERGE
Hi all,
Can you help me in converting this update statement into merge? I will really appreciate your help. Thanks
UPDATE dm_organizations tt
SET (cost_ctr_desc, cost_ctr_hier_lvl_1, cost_ctr_hier_lvl_2,
cost_ctr_hier_lvl_3, cost_ctr_hier_lvl_4, cost_ctr_hier_lvl_5, rgn_nm,
cntry_nm, load_date, update_date) =
(SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
t.cntry_nm, t.load_date, SYSDATE
FROM dmi_cc_upload_stg t
WHERE t.run_id = 1831
AND t.status = 'Published'
AND t.cost_ctr_id = tt.cost_ctr_id
AND t.div_code = tt.div_code
AND t.fcn_code = tt.fcn_code
AND t.mkt_code = tt.mkt_code
AND t.corp_id = tt.corp_id
AND ROWNUM = 1)
WHERE EXISTS (
SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
t.cntry_nm, t.load_date, SYSDATE
FROM dmi_cc_upload_stg t
WHERE t.run_id = 1831
AND t.status = 'Published'
AND t.cost_ctr_id = tt.cost_ctr_id
AND t.div_code = tt.div_code
AND t.fcn_code = tt.fcn_code
AND t.mkt_code = tt.mkt_code
AND t.corp_id = tt.corp_id);Duplicate thread!
PLS HELP CONVERT QUERY FROM UPDATE TO MERGE
Maybe you are looking for
-
Hello there, Suddenly my Mac has lost all Fire Wire ports Any advice please will be much appreciated Message was edited by: another new convert
-
I set up new MobileMe Family Acct. How do I redirect ITouch and MacBk sync?
I set up a new MobileMe account, another Family-pack member. I want to get my MacBook and ITouch to sync contacts, calendar, etc with the new MobileMe account name. My ITouch is still syncing with the old name. On MacBook, I reset the MobileMe name i
-
Can I view and edit another iCloud calendar on my iPhone?
Both me and my wife have iPhones and both have our own iCloud accounts. Can we share calendars so we both use the same one whilst still using our own individual iCloud accounts?
-
Hi everybody, i have 2 databases d01 and d02. i have same no and same objects on both the databases. i am exporting data for 1 subscriber from d01 and importing into d02.during importing data to d02 first i disable all constraints of the tables in d0
-
since firefox 4.0 i get problems with sites the contain a search engine. Google works fine, but for an example: http://stagemarkt.nl/zoekresultaten.aspx?c=95070&p=eindhoven This is a site to search job offers in the netherlands for education. It simp