stored-procedures

XML parsing illegal character in sql server

谁都会走 提交于 2020-07-21 07:15:07
问题 I am greeted with an illegal xml character error when parsing a table record into xml. SELECT mb.ProductTitle,mb.ProductDescription, CAST(( SELECT Id, ProductDescription, FROM ProductsManagement AS mpm WHERE mpm.MattressId = 6 FOR XML PATH('ProductItemListModel'), ROOT('MattressBarndProductItemList'))as XML) FROM Brands AS mb WHERE mb.Id = 6 FOR XML PATH(''), ROOT('ProductModel') or SELECT CONVERT(XML,'lift') The record for the description is as follows: Ease™ by Sealy adjustable base is the

XML parsing illegal character in sql server

旧街凉风 提交于 2020-07-21 07:14:47
问题 I am greeted with an illegal xml character error when parsing a table record into xml. SELECT mb.ProductTitle,mb.ProductDescription, CAST(( SELECT Id, ProductDescription, FROM ProductsManagement AS mpm WHERE mpm.MattressId = 6 FOR XML PATH('ProductItemListModel'), ROOT('MattressBarndProductItemList'))as XML) FROM Brands AS mb WHERE mb.Id = 6 FOR XML PATH(''), ROOT('ProductModel') or SELECT CONVERT(XML,'lift') The record for the description is as follows: Ease™ by Sealy adjustable base is the

How can I increment the value for each INSERT INTO iteration?

假装没事ソ 提交于 2020-07-19 05:27:14
问题 I have a Query as shown below column1 is int anothercolumn is varchar(100) INSERT INTO TABLE1 (column1,column2) SELECT (MAX(column1) FROM TABLE1)+1 ,anotherColumn FROM TABLE2 Table1 Before Query column1 column2 ------- ------- 3 test1 4 test2 Table1 After Query column1 column2 ------- ------- 3 test1 4 test2 5 anotherVal1 5 anotherVal2 5 anotherVal3 But I want column1 column2 ------- ------- 3 test1 4 test2 5 anotherVal1 6 anotherVal2 7 anotherVal3 How can I achieve this in SQLserver 2008

How can I increment the value for each INSERT INTO iteration?

丶灬走出姿态 提交于 2020-07-19 05:27:10
问题 I have a Query as shown below column1 is int anothercolumn is varchar(100) INSERT INTO TABLE1 (column1,column2) SELECT (MAX(column1) FROM TABLE1)+1 ,anotherColumn FROM TABLE2 Table1 Before Query column1 column2 ------- ------- 3 test1 4 test2 Table1 After Query column1 column2 ------- ------- 3 test1 4 test2 5 anotherVal1 5 anotherVal2 5 anotherVal3 But I want column1 column2 ------- ------- 3 test1 4 test2 5 anotherVal1 6 anotherVal2 7 anotherVal3 How can I achieve this in SQLserver 2008

How to run snowflake side effect functions like SYSTEM$GENERATE_SCIM_ACCESS_TOKEN within a procedure with owner rights?

两盒软妹~` 提交于 2020-07-16 07:59:07
问题 Basically I want to do SCIM integration in snowflake. For that I have to use this command for getting the token which will be passed to Azure AD: call system$generate_scim_access_token('<value>'); This command can only run with AccountAdmin. And running it with AccountAdmin I am able to get token but In future I will not be having rights of AccountAdmin, so for that what I did, I created a procedure with AccountAdmin and execute it as owner. So that, when ever any other role which is having

Update multiple columns based on percentage wise calculation in Oracle

心不动则不痛 提交于 2020-07-13 15:14:04
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. hud is looking for an answer from a reputable source : Looking for the answer for question NOTE: Updating total question with sample data and output. I need to update some columns by comparing from another table and update the columns percentage wise. So here I go. first of all , the query to get CMM approved length is below with other columns which I need select CIRCLE,regexp_substr(MP,'[^/]+',1

Oracle - Why is EXECUTE IMMEDIATE allowed in stored procedures?

可紊 提交于 2020-07-09 14:42:14
问题 Why is EXECUTE IMMEDIATE allowed in stored procedures, if stored procedures are meant to mitigate SQL injection attacks? The accepted answer to the following question refers to them as a step against such attacks: What is a stored procedure? https://stackoverflow.com/a/459531/3163495 "Stored procedures also have a security benefit in that you can grant execute rights to a stored procedure but the user will not need to have read/write permissions on the underlying tables. This is a good first

Using Optional parameters when incoming value is null?

左心房为你撑大大i 提交于 2020-07-09 12:16:06
问题 I have a stored procedure that looks like the following. Let's say I call the procedure usp_Exclusion 'Joe', null, 'Bob' , what would I need to do in the stored procedure so that the null value changes to a string (in this case, '')? Unless it's the only way, I don't want to go through every parameter and set to a string if it's null. ALTER procedure dbo.usp_Exclusion ( @exclude1 varchar(100) = '', @exclude2 varchar(100) = '', @exclude3 varchar(100) = '' ) as declare @table table ( EmpName

How to get result set from PostgreSQL stored procedure?

非 Y 不嫁゛ 提交于 2020-07-08 19:29:24
问题 I created a stored procedure in PostgreSQL 11 to perform CRUD operation, and it works fine for 1. Create 2. Update 3. Delete, but while I run read command by passing Condition = 4 to select a result set, I get below error. I have used PostgreSQL function to get result set it works for me, but I need to get result using the PostgreSQL stored procedure. Here is my code for stored procedure: CREATE OR REPLACE PROCEDURE public.testSpCrud( fnam text, lnam text, id integer, condition integer)

How to get result set from PostgreSQL stored procedure?

喜你入骨 提交于 2020-07-08 19:28:33
问题 I created a stored procedure in PostgreSQL 11 to perform CRUD operation, and it works fine for 1. Create 2. Update 3. Delete, but while I run read command by passing Condition = 4 to select a result set, I get below error. I have used PostgreSQL function to get result set it works for me, but I need to get result using the PostgreSQL stored procedure. Here is my code for stored procedure: CREATE OR REPLACE PROCEDURE public.testSpCrud( fnam text, lnam text, id integer, condition integer)