Aggregate NOT Permitted In "set" List Of Update

Jan 21, 2002

Can anyone tell me how to UPDATE a column w/ an aggregate value (sum) w/in an UPDATE statement?

I receive the error: "An aggregate may not appear in the set list of an UPDATE statement" in the follwoing code:

update TabAAA set A.col_777 = sum(A.Salary)
from TabAAA A TabBBB B,
where (A.col_1 = B.col_1)
and (A.col_2 = B.col_2)

View 2 Replies


ADVERTISEMENT

SQL Server 2012 :: Column X Is Invalid In Select List Because It Is Not Contained In Aggregate Function

Apr 3, 2015

I have a specific variation on the standard 'Column Invalid' question: I have this query that works fine:

SELECT vd.Question ,
csq.Q# ,
csq.Q_Sort ,
csq.Q_SubSort ,
AVG(CAST(vd.Response AS FLOAT)) AS AvgC ,
vd.RType

[Code] ....

When I add this second average column like this:

SELECT vd.Question ,
csq.Q# ,
csq.Q_Sort ,
csq.Q_SubSort ,
AVG(CAST(vd.Response AS FLOAT)) AS AvgC ,

[Code] ....

I get the error: Column 'dbo.vwData.Response' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Clearly things are in the right place before the change, so I can only assume that the OVER clause is my problem. Is this just not possible?

View 1 Replies View Related

Aggregate Function Update

Mar 8, 2004

I am trying to write an update statement based on an aggregate and it will not let me. Please find below the SQL.

update abtimesummary
set hours = sum(a.hours)
from abtimestore a
join abtimesummary b
on (cast(a.weekno as varchar(10)))+'-'+(cast(a.empno as varchar(10))) = b.summaryid

and this is the error message:

Server: Msg 157, Level 15, State 1, Line 2
An aggregate may not appear in the set list of an UPDATE statement.

Can someone tell me how to get round this please?

Many thanks

View 2 Replies View Related

UPDATE Using Aggregate And Inner Join

Aug 24, 2004

I want the sum of an amount to update another table using inner join.

The following query -

UPDATE A
SET A.[Col3] = SUM(B.[Col3])
FROM A
INNER JOIN B
ON A.C1 = B.C1
ANDA.C2= B.C2

Gives me an error saying I cannot use SET with aggregate Column.

How do I perform this aggregate update?

Thanks,

Vivek

View 1 Replies View Related

Aggregate May Not Appear In An UPDATE Statement

Aug 20, 2007

I am trying to update a field in a table with the most recent event_date. However, I am receiving the following error:


Msg 157, Level 15, State 1, Line 1

An aggregate may not appear in the set list of an UPDATE statement.

My code appears below:

----------------

update mraOI

set mraOI.event_history_key = eh.event_history_key,

mraOI.event_date = MAX(eh.event_date),

mraOI.event_time = eh.event_time,

mraOI.event_type_key = eh.event_type_key,

mraOI.item_key = eh.item_key,

mraOI.associated_item_ke = eh.associated_item_ke

FROM reports.MedRecActionOI mraOI INNER JOIN

srm.EVENT_HISTORY eh ON mraOI.CC_episode_key = eh.item_key
-----------------


Can someone suggest a better method or a work around?

View 3 Replies View Related

UPDATE Another Table Using Aggregate Function

May 22, 2008

Here is the example:

I have two tables. One has Projects with the total amt of hours worked on the project itself. The other is an Employee_Projects table with individual rows of hrs per employee worked on the above referenced projects.

I need to SUM all the hrs from the Employee_Projects table and GROUP BY project number, then UPDATE the Projects table with the sum of hours where the Project Number from table A matches the Project Number from table B.

Of course, you cant use an aggregate function in an UPDATE clause, so what would be the easiest way to do this??

Any help would be much appreciated.

-C

View 2 Replies View Related

Update Using Group By And Aggregate Function

Jan 22, 2004

I'm trying to update a varchar field using SUM. I keep getting the error that the sub query returns more than one value.

UPDATE CIRSUB_M
SET TRM_DMO = SUBSTRING(TRM_DMO,1,11) +
(SELECT CAST(SUM(COPIES) AS VARCHAR(5)) FROM CIRSUB_M
WHERE BIL_ORG = '02' AND CRC_STS IN ('R','P','Q','T')
GROUP BY PUB_CDE, DNR_NBR)
WHERE BIL_ORG = '02' AND CRC_STS IN ('R','P','Q','T')

Example

PUB_CDE DNR_NBR COPIES TRM_DMO
THN 000000092637 100 A
THN 000000092637 200 B
THN 000000082455 100 A
THN 000000082455 200 B
THN 000000051779 100 A

Updated
THN 000000092637 100 A300
THN 000000092637 200 B300
THN 000000082455 100 A300
THN 000000082455 200 B300
THN 000000051779 100 A100

View 4 Replies View Related

UPDATE RECORDS WITH AGGREGATE FUNCTION

Mar 2, 2007

Problem is very simple

I want to update sum of a field from another table to first table

TABLE ONE:
==========
ItemID
QtyInStock


Table TWO:
==========
BatchID
ItemID
Qty

I want to Update the QtyInStock of First Table with Sum(Batch.Qty)

here is the query i am writing but giving error

UPDATE ITEMS
SET
INSTOCKQTY=CASE WHEN QtyInBatch>1 THEN QTYINBATCH ELSE 0 END
FROM ITEMS, (
SELECT ITEMS.ITEMID, SUM(Batch.Qty) AS QtyInBatch FROM Batch INNER JOIN Items ON Batch.ItemID = Items.ItemID GROUP BY ITEMS.ITEMID
)

appericiating anyones help in advance




FAZEEL AMJAD
Systems Engineer
Crystal Technologies

View 4 Replies View Related

Update Table With Joins And Aggregate Function

Apr 3, 2007

Is this possible? What I am looking for is something like:UPDATE T_SitesSET T_Sites.LastDate = T_Inspections.DateFROM T_SitesINNER JOIN T_Assets ON T_Sites.SiteID = T_Assets.AssetIDLEFT OUTER JOIN T_Insecptions ON T_Assets.AssetID = T_Inspections.AssetID-- But I need only the last inspection done on the site (including if it is null) 

View 1 Replies View Related

SQL Server 2008 :: Aggregate In Update Statement

Apr 16, 2015

I'm getting the following error message 'An aggregate may not appear in the set list of an UPDATE statement' What is the proper way to carry out an update on aggregates?

My code is below:

t1.TotalTest1 = coalesce(Sum(t2.AmountTest1), 0.00),
t1.TotalTest2 = coalesce(Sum(t2.AmountTest2), 0.00),
t1.TotalTest3 = coalesce(Sum(t2.AmountTest3), 0.00),
t1.TotalTest4 = coalesce(Sum(t2.AmountTest4), 0.00),

from #tbl_CHA t1
inner join

[Code] ....

View 4 Replies View Related

UPDATE A Table With Aggregate Results For Multiple Columns

Jan 8, 2007

Hi everyone. I am updating a table with aggregate results for multiplecolumns. Below is an example of how I approached this. It works finebut is pretty slow. Anyone have an idea how to increase performance.Thanks for any help.UPDATE #MyTableSET HireDate=(Select Min(Case When Code = 'OHDATE' then DateChangedelse null end)From HREHWhere #MyTable.HRCo=HREH.HRCo and#MyTable.HRRef=HREH.HRRef ),TerminationDate=(select Max(Case When Type = 'N' thenDateChanged else null end)From HREHWhere #MyTable.HRCo=HREH.HRCo and#MyTable.HRRef=HREH.HRRef ),ReHireDate=(select MAX(Case When Code = 'HIRE' thenDateChanged else null end)From HREHWhere #MyTable.HRCo=HREH.HRCo and #MyTable.HRRef=HREH.HRRef )

View 2 Replies View Related

Cannot Perform An Aggregate Function On An Expression Containing An Aggregate Or A Subquery.

Oct 19, 2007

Can any1 tell me why i am getting an error


SELECT DISTINCT

--p.voucher,

--p.amount,

p.siteID,

b.siteID,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS OutStandingBalance,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS CashCheque,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS Vouchers

FROM

BillingTotal b,

Payment p

--WHERE

-- s.sitename=@cmb1

--AND p.siteid = s.siteid

-- p.voucher = 0

-- p.voucher = 1

GROUP BY p.siteID,b.siteID



Msg 130, Level 15, State 1, Line 1

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

View 8 Replies View Related

Analysis :: Calculated Member From Aggregate And Non-aggregate Factors

Sep 22, 2015

I have 2 Dimensions in SSAS (see below end), I want to create a calculated member, named

This_Year_Billable_Objective_Count, with its formula = BillableLastYear*(100+ BillableObjective)/100.

The first factor,  BillableLastYear is a number, aggregated (sum) from child units.

The second factor,  BillableObjective is a percent number (for example 28 means 28%), it's not aggregate. It's an dependent value for each unit.

How can I calculate This_Year_Billable_Objective_Count for each unit?

\ able 1
SELECT [UnitKey]
      ,[UnitID]
      ,[UnitName]
      ,[Unit2Name]
      ,[Unit3Name]
      ,[Unit4Name]

[Code] .....

View 6 Replies View Related

The Name ' ' Is Not Permitted - Error

Sep 25, 2007

Hi Everyone,
  I've run into a problem I have not seen before, and a Google search did not turn up any useful info. So, I'm back to ask for help here! I have created an INSERT statement and several columns are boolean. When I try to execute the INSERT, I get the following error:
The name "False" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
  I've found that this is Error MSG 128. Also, I'm executing the command as a transaction. The first command is a DELETE followed by an INSERT. The DELETE is working fine, but the INSERT is causing this error. Here is the code for assembling the 2 SQL statements. string[] SQLCommands = new string[RecordCount+1];
int SQLCount = 0;
StringBuilder stb = new StringBuilder();

stb.Append("DELETE FROM UserRights WHERE UserIDPtr = '");
stb.Append(TargetUserID);// Guid value
stb.Append("';");
SQLCommands[SQLCount++] = stb.ToString();
stb.Remove(0, stb.Length);

foreach (MyApp.UserRightsRow row in TargetUserRights)
{
stb.Append("INSERT INTO [UserRights] ");
stb.Append("([UserIDPtr], [AllCustomersFlag], [Customer], [CustomerFlag], [Region], [RegionFlag], [Plant], [PlantFlag], ");
stb.Append("[Building], [BuildingFlag], [Area], [AreaFlag], [Active], [UpdatedBy], [Updated]) ");
stb.Append("VALUES ('");
stb.Append(row.UserIDPtr);// Guid value
stb.Append("', ");
stb.Append(row.AllCustomersFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Customer.ToString());// int
stb.Append(", ");
stb.Append(row.CustomerFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Region.ToString());// int
stb.Append(", ");
stb.Append(row.RegionFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Plant.ToString());// int
stb.Append(", ");
stb.Append(row.PlantFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Building.ToString());// int
stb.Append(", ");
stb.Append(row.BuildingFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Area.ToString());// int
stb.Append(", ");
stb.Append(row.AreaFlag.ToString());// bit
stb.Append(", ");
stb.Append(row.Active.ToString());// bit
stb.Append(", '");
stb.Append(row.UpdatedBy);// Guid value
stb.Append("', ");
stb.Append(row.Updated);// DateTime value
stb.Append("); ");

SQLCommands[SQLCount++] = stb.ToString();
stb.Remove(0, stb.Length);
}
The method that performs the SQL Transaction is: public bool DoTransaction(string[] SQLStatements)
{
int i;
int SQLStatementCount = SQLStatements.Length;

using (SqlConnection MyConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("cnMyApp")))
{
using (SqlCommand command = MyConnection.CreateCommand())
{
SqlTransaction transaction = null;

try
{
MyConnection.Open();

transaction = MyConnection.BeginTransaction();

command.Transaction = transaction;

for (i = 0; i < SQLStatementCount; i++)
{
command.CommandText = SQLStatements[i].ToString();
command.ExecuteNonQuery();
}

transaction.Commit();
return true;
}
catch
{
transaction.Rollback();
throw;
}
finally
{
MyConnection.Close();
}
}
}
} Any help with this would be greatly appreciated!! Thanks!

View 2 Replies View Related

Not Permitted In This Context

Jul 19, 2006

Hi,I am having a SQL Server 2005 problem with my Insert statement. I amsending a command via my website to my database. It comes up with anerror I'll put below. The code is here:"INSERT INTO tblUsers (userName) VALUES ( userNameTest)"This is the error I get:The name "userNameTest" is not permitted in this context. Validexpressions are constants, constant expressions, and (in some contexts)variables. Column names are not permitted.Now, userName is a varchar field in the database. What is wrong?Kivak

View 2 Replies View Related

Subquery Returned More Than One Value That Is Not Permitted

Jan 23, 2013

Am getting error:- Subquery returned more than one value,that is not permitted when sub query follows

=,<,>.................................Below is my query
declare @WorkOrder as nvarchar(10)
Set @WorkOrder =( Select X.PrjCode from OPRJ X Where X.PrjCode='[%1]')

SELECT L.Project ,l.U_PINo as [Indent No], M.DocNum AS 'GRN No', M.DocDate as 'Date',
M.CardName as 'Vendor Name',L.ItemCode,l.Dscription,l.Quantity,l.unitMsr as'UOM',l.Price,l.DiscPrcnt ,L.LineTotal,
isnull((SELECT (TaxSum) FROM PDN4 where statype=-90 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0) +

[Code] .....

View 1 Replies View Related

Comma Delimited List Update Stored Procedure

Jan 15, 2005

I have a stored procedure that I want to use to update multiple records. I'm using ASP and the request form collection is returning values in a comma delimited list.
Example:
name1 = value1, value2, value3, etc.
name2 = value1, value2, value3, etc.
name3 = value1, value2, value3, etc.

Here is how I wrote my stored procedure:

CREATE PROCEDURE dbo.Sp_Update_ABR_Record
(
@abrID int,
@ddo varchar(50),
@ay varchar(50),
@strategy varchar(10),
@budgacct varchar(10),
@budgobj varchar(10),
@origamt
varchar(50),
@incrdecr varchar(50),
@review char(10),
@abrdetlsID varchar(50)
)
AS
UPDATE DIM_ABR_REQ_HDR
SET ABR_review = @review
WHERE ABR_ID = @abrID

UPDATE DIM_ABR_REQ_DETLS
SET ABR_DETLS_DDO = @ddo, ABR_DETLS_AY = @ay,
ABR_DETLS_STRATEGY = @strategy, ABR_DETLS_BUDG_ACCT = @budgacct,
ABR_DETLS_BUDG_OBJ = @budgobj, ABR_DETLS_FUND_ORIG_AMT = convert(money, @origamt), ABR_DETLS_FUND_INCR_DECR = convert(money, @incrdecr)
WHERE
ABR_DETLS_ID = @abrdetlsID
GO

The second update is where the comma delimited list needs to be handled. The first update is only updating one field once.

Is there a way to write the procedure to handle the comma delimited list? Or, is the way I have the stored procedure okay and I just need to handle the comma delimited list within the ASP code? I'm not sure which way I can accomplish this?

Thanks for any help.
-D-

View 5 Replies View Related

Reporting Services :: Could Not Update List Of Fields For Query

Oct 7, 2015

I have the following store procedure which execute perfectly fine Under SSMS as it is :

-- Insert statements for procedure here
SELECT APHIST.ReturnDate AS ATDATE
,API_HIST.[ActionPlanItemID]
,API_HIST.[ActionPlanID]
,PIT.[ProductItemID]
,PIT.ProductItemCode

[Code] ....

But then when I try to create a dataset using ReportBuilder and pointing to that StoreProcedure, I get the following error message box :

"Could not update a list of fields for the query. Verify that you can connect to the data source and that your query syntax is correct. An  item with same key already been added" ...

View 3 Replies View Related

DB Design :: Update List Of Records In A Table With New Value Depending On Old Value

Jun 15, 2015

I have a table called acc1152 with the field accno. depending on what the value of this field is, i need to replace it with a new value. These are the values i need to update

old value new value
7007 4007
7008 4008
4008 7
7009 4009
7011 4011
4011 ' '
7010 4010
4010 1
7016 4016
4016 1
4506 4006
4512 4012

how do I write one query that will accomplish this?

View 3 Replies View Related

0x80040e14 - The Name 'nameHere' Is Not Permitted In This Context

Nov 6, 2006

To all,
I have previously read from and saved to Access databases, but now decided to attempt to learn more about using SQL databases. I took an ASP.NET page I had previously used to save data to an access database and attempted to repurpose it to be used with a SQL database with the same content. I get an error that I have spent the past 3 hours researching on the internet. I am unable to find a solution that fits my code formatting. Any help that could be given would be greatly appreciated.
When I run my ASP.NET page I get the following error:"The name 'newsID' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted."
The code I am using is shown below:---------------------------------------------------------------------------------------------------------------------Dim objCommand As OleDbCommandDim strSQLQuery As String
strSQLQuery = "INSERT INTO news " _& "(ID, newsDate, newsComp, newsInfo) " _& "VALUES (newsID, newsDate, newsComp, newsInfo)"
objCommand = New OleDbCommand(strSQLQuery, objConnection)  objCommand.Parameters.Add(New OleDbParameter("newsID", OleDbType.Integer))objCommand.Parameters.Add(New OleDbParameter("newsDate", OleDbType.DBTimeStamp))objCommand.Parameters.Add(New OleDbParameter("newsComp", OleDbType.VarChar))objCommand.Parameters.Add(New OleDbParameter("newsInfo", OleDbType.LongVarChar))
objCommand.Parameters("newsID").Value = "1"objCommand.Parameters("newsDate").Value = "11/06/2006"objCommand.Parameters("newsComp").Value = "Company Name"objCommand.Parameters("newsInfo").Value = "A description of the news items here"
objConnection.Open()objCommand.ExecuteNonQuery()objConnection.Close()---------------------------------------------------------------------------------------------------------------------

View 5 Replies View Related

Access To Database File Is Not Permitted.

Jan 31, 2008

I've done some programming before, but i'm pretty much a novice in C#. I recently installed Visual Studio 2008 Express Edition. For some reason, when i came to a point to make a connection with an SQL Sample database "NORTHWIND.SDF".... An error message show up saying "access to database file is not permitted". What causes it.???

View 1 Replies View Related

The Name 'HeaderID' Is Not Permitted In This Context. Only Constants, Expressions, Or

Oct 5, 2007

I'm pulling data from one database in which the headerID is the primary key which automatically increases by one on each insert. Modifying all of the other fields from one data type to another and then inserting them into another database after the convertion is done. I keep getting this error.

The name 'HeaderID' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

INSERT INTO [DatabaseName].[dbo].[InvoiceHeaderConverted]
([HeaderID], [InvoiceNumber], [StoreNumber], [DeliveryDate], [DueDate],
[TotalInvoice], [TotalTax], [ManifestNumber])
VALUES(HeaderID = @HeaderID, InvoiceNumber = @InvoiceNumber, StoreNumber = @StoreNumber,
DeliveryDate = @DeliveryDate, DueDate = @DueDate, TotalInvoice = @TotalInvoice,
TotalTax = @TotalTax, ManifestNumber = @ManifestNumber)

Can anyone point me in the right direction on this one. The headerid isn't autogenerated in the second database but is still the primary key.

View 4 Replies View Related

Object Is Invalid. Extended Properties Are Not Permitted On ...

Mar 2, 2006

when attempting to execute the following query from within 2005 Mgmt Studio:

sp_dropextendedproperty

@name = 'test_me'

, @level0type = 'schema'

, @level0name = 'dbHSPS.dbo'

, @level1type = 'table'

, @level1name = 'Conflict'

/*[ , [ @level2type = 'column'] { 'level2_object_type' }

, [ @level2name = ] { 'level2_object_name' }

] */



I receive:

"Object is invalid. Extended properties are not permitted on 'dbHSPS.dbo.Conflict', or the object does not exist."



However I can SELECT * FROM dbHSPS.dbo.Conflict and it returns results, and I know the test_me extended property exists for table "Conflict" in dbHSPS.dbo ...

View 4 Replies View Related

No External Connections Are Permitted While Trying To Connect To SQL Server

Apr 9, 2007

ok so this is my code:



private void iDListBox_SelectedIndexChanged(object sender, EventArgs e)

{

string connectionString = GetConnectionString();

using (SqlConnection connection = new SqlConnection(connectionString))

{

SqlCommand cmd = new SqlCommand("SELECT * FROM Table1 WHERE Naam=@Naam", connection);

cmd.Parameters.AddWithValue("@Naam", iDListBox.SelectedValue);

connection.Open();

SqlDataReader reader = cmd.ExecuteReader();

if (reader.Read())

{

naamTextBox.Text = reader.GetString(1);

}

reader.Dispose();

connection.Dispose();

}

}



static private string GetConnectionString()

{

return "Data Source=(local);Initial Catalog=AdventureWorks;"

+ "Integrated Security=SSPI;";

}



but when I change the selected index of the listbox, then this error comes up:

System.Data.SqlClient.SqlException was unhandled
Message="An error occured while setting up a connection with the server. At making a connection with SQL server 2005, this jamming is possibly caused by the fact that at the standardinstitutions of SQL server no external connections have been permitted (provider: Provider of named pipes, error: 40 - no connection with SQL could open server)"

If the error sounds a bit weird, sry I tried to translate as most of my errors come in my language



someone knows what the problem is and a solution to it?



(btw sry if this is in the wrong part of the sql forum, but there are so much parts, I didn't know which to choose lol )



thx in advance

View 1 Replies View Related

SQL Tools :: Saving Changes Is Not Permitted - Warning When Try To Save Changes

Sep 15, 2011

I have a table that I am an dbo  owner and when I try to move a column from the last to the first position in Design table mode and click to save, I am getting the following warning:"Saving changes is not permitted. The changes you have made require the following tables to be dropped or re-created.   You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to the re-created"..how to deal with this error so that I can move my column in a table Design mode.  I am on SS 2008 R2.

View 5 Replies View Related

Mssql 2000 Replication Error Number 128- The Name ' ' Is Not Permitted ....

May 14, 2007

Hi.. I tried to setup MSSQL2000 trans replicatiom using push subscription method. My Publisher is also my distributor. But whenever I started the dstribution agent, I got the following error. It has problem connecting to subscriber's DB with the following error. I had tried that the login is 100% fine. But why this error appear ? Any help?

The name ' ' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
(Source: Subsriber (Data source); Error number: 128)

View 1 Replies View Related

Error: The Backup Of The File Or Filegroup Sysft_XXXX_FT Is Not Permitted Because It Is Not Online

Aug 22, 2006

Hi There,

I am trying to do a full back up of a user database which has full text indexing on it. I use the maintenance plan wizard to set up a full backup. For some reason, I get this error.

=================

Executing the query "BACKUP DATABASE [XXXX] TO [XXXX]
WITH NOFORMAT, NOINIT, NAME = N'XXXX_backup_20060819040020', SKIP, REWIND, NOUNLOAD, STATS = 10
" failed with the following error:
"The backup of the file or filegroup "sysft_XXXX_FT" is not permitted because it is not online.
BACKUP can be performed by using the FILEGROUP or FILE clauses
to restrict the selection to include only online data.
BACKUP DATABASE is terminating abnormally.".
Possible failure reasons: Problems with the query,
"ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

===============

Can anybody please suggest me what I should do?

Thanks.

View 19 Replies View Related

Reporting Services :: Report Server Email Configuration - Permitted Hosts

Aug 25, 2015

I would like to configure the permitted hosts setting for the Report Server. According to MSDN, the Syntax is:

 <PermittedHosts>
          <HostName>Adventure-Works.com</HostName>
          <HostName>hotmail.com</HostName>
     </PermittedHosts>

In case of having only one host, is the <HostName> tag mandatory? I was not able to find more information regarding the xsd on which the configuration file is based. To be more specific, is it possible to define the PermittedHost like this or will this result in an error?

 <PermittedHosts>Adventure-Works.com</PermittedHosts>

View 3 Replies View Related

How To Aggregate A Column That Was Itself An Aggregate

Jul 15, 2005

I have a column that has an expression with a runningvalue in it, a "Carrying Cost" for each month. I need to create another column that aggregates the monthly Cost. I can't to do a Runningvalue on the Runingvalue. I can't even do a Sum on the Runningvalue.

View 9 Replies View Related

Valid Expressions Are Constants, Constant Expressions, And (in Some Contexts) Variables. Column Names Are Not Permitted.

Dec 11, 2007

I want to have this query insert a bunch of XML but i get this error...


Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 117

The name "ExpenseRptID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 151

The name "DateWorked" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

What am i doing wrong...Can anyone help me out!! Thanks!!

p.s I know this query looks crazy...


Code Block

IF EXISTS (SELECT NAME FROM sysobjects WHERE NAME = 'InsertTimeCard' AND type = 'P' AND uid=(Select uid from sysusers where name=current_user))
BEGIN
DROP PROCEDURE InsertTimeCard
END
go
/*********************************************************************************************************
** PROC NAME : InsertTimeCardHoursWorked
**
** AUTHOR : Demetrius Powers
**
** TODO/ISSUES
** ------------------------------------------------------------------------------------
**
**
** MODIFICATIONS
** ------------------------------------------------------------------------------------
** Name Date Comment
** ------------------------------------------------------------------------------------
** Powers 12/11/2007 -Initial Creation
*********************************************************************************************************/
CREATE PROCEDURE InsertTimeCard
@DateCreated DateTime,
@EmployeeID int,
@DateEntered DateTime,
@SerializedXML text,
@Result int output
as
declare @NewTimeCardID int
select @NewTimeCardID = max(TimeCardID) from OPS_TimeCards
-- proc settings
SET NOCOUNT ON

-- local variables
DECLARE @intDoc int
DECLARE @bolOpen bit
SET @bolOpen = 0
--Prepare the XML document to be loaded
EXEC sp_xml_preparedocument @intDoc OUTPUT, @SerializedXML
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler
--The document was prepared so set the boolean indicator so we know to close it if an error occurs.
SET @bolOpen = 1


--Create temp variable to store values inthe XML document
DECLARE @tempXMLTimeCardExpense TABLE
(
TimeCardExpenseID int not null identity(1,1),
TimeCardID int,
ExpenseRptID int,
ExpenseDate datetime,
ProjectID int,
ExpenseDescription nvarchar(510),
ExpenseAmount money,
ExpenseCodeID int,
AttachedRct bit,
SubmittoExpRep bit
)
DECLARE @tempXMLTimeCardWorked TABLE
(
TimeCardDetailID int not null identity(1,1),
TimeCardID int,
DateWorked DateTime,
ProjectID int,
WorkDescription nvarchar(510),
BillableHours float,
BillingRate money,
WorkCodeID int,
Location nvarchar(50)
)
-- begin trans
BEGIN TRANSACTION
insert OPS_TimeCards(NewTimeCardID, DateCreated, EmployeeID, DateEntered, Paid)
values (@NewTimeCardID, @DateCreated, @EmployeeID, @DateEntered, 0)
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler


--Now use @intDoc with XPATH style queries on the XML
INSERT @tempXMLTimeCardExpense (TimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
SELECT @NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep
FROM OPENXML(@intDoc, '/ArrayOfTimeCardExpense/TimeCardExpense', 2)
WITH ( ExpenseRptID int 'ExpenseRptID',
ExpenseDate datetime 'ExpenseDate',
ProjectID int 'ProjectID',
ExpenseDescription nvarchar(510) 'ExpenseDescription',
ExpenseAmount money 'ExpenseAmount',
ExpenseCodeID int 'ExpenseCodeID',
AttachedRct bit 'AttachedRct',
SubmittoExpRep bit 'SubmittoExpRep')
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- remove XML doc from memory
EXEC sp_xml_removedocument @intDoc
SET @bolOpen = 0


INSERT OPS_TimeCardExpenses(TimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
Values(@NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
select @NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep
from @tempXMLTimeCardExpense
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- For time worked...
INSERT @tempXMLTimeCardWorked(TimeCardID, DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
SELECT @NewTimeCardID, DateWorked, ProjectID, WorkDescription, BilliableHours, BillingRate, WorkCodeID, Location
FROM OPENXML(@intDoc, '/ArrayOfTimeCardWorked/TimeCardWorked', 2)
WITH ( DateWorked DateTime 'DateWorked',
ProjectID datetime 'ProjectID',
WorkDescription nvarchar(max) 'WorkDescription',
BilliableHours float 'BilliableHours',
BillingRate money 'BillingRate',
WorkCodeID int 'WorkCodeID',
Location nvarchar(50)'Location')
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- remove XML doc from memory
EXEC sp_xml_removedocument @intDoc
SET @bolOpen = 0


INSERT OPS_TimeCardHours(TimeCardID, DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
Values(@NewTimeCardID,DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
select @NewTimeCardID ,DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location
from @tempXMLTimeCardWorked


-- commit transaction, and exit
COMMIT TRANSACTION
set @Result = @NewTimeCardID
RETURN 0

-- Error Handler
ErrorHandler:
-- see if transaction is open
IF @@TRANCOUNT > 0
BEGIN
-- rollback tran
ROLLBACK TRANSACTION
END
-- set failure values
SET @Result = -1
RETURN -1

go

View 1 Replies View Related

SQL 2012 :: List All Different Values That Go With Single CAS ID To Appear As Comma Separate List

Jun 15, 2015

So at the moment, I don't have a function by the name CONCATENATE. What I like to do is to list all those different values that go with a single CASE_ID to appear as a a comma separate list. You might have a better way of doing without even writing a function

So the output would look like :

CASE_ID VARIABLE
=====================
1 [ABC],[HDR],[GHHHHH]
2 [ABCSS],[CCHDR],[XXGHHVVVHHH],[KKKJU],[KLK]

SELECT
preop.Case_ID,
dbo.Concatenate( '[' + CAST(preop.value_text AS VARCHAR) + ']' ) as variable
FROM
dbo.TBL_Preop preop
WHERE
preop.Deleted_CD = 0

GROUP BY
preop.Case_ID

View 8 Replies View Related

Report Designer: Need To List Fields From Multiple Result Rows As Comma Seperated List (like A JOIN On Parameters)

Apr 9, 2008



I know I can do a JOIN(parameter, "some seperator") and it will build me a list/string of all the values in the multiselect parameter.

However, I want to do the same thing with all the occurances of a field in my result set (each row being an occurance).

For example say I have a form that is being printed which will pull in all the medications a patient is currently listed as having perscriptions for. I want to return all those values (say 8) and display them on a single line (or wrap onto additional lines as needed).

Something like:
List of current perscriptions: Allegra, Allegra-D, Clariton, Nasalcort, Sudafed, Zantac


How can I accomplish this?

I was playing with the list box, but that only lets me repeat on a new line, I couldn't find any way to get it to repeate side by side (repeat left to right instead of top to bottom). I played with the orientation options, but that really just lets me adjust how multiple columns are displayed as best I can tell.

Could a custom function of some sort be written to take all the values and spit them out one by one into a comma seperated string?

View 21 Replies View Related

Insert Value List Doest Not Match Column List

Apr 18, 2007

HI...



I need to do a simple task but it's difficult to a newbie on ssis..



i have two tables...



first one has an identity column and the second has fk to the first...



to each dataset row i need to do an insert on the first table, get the @@Identity and insert it on the second table !!



i'm trying to use ole db command but it's not working...it's showing the error "Insert Value list doest not match column list"



here is the script



INSERT INTO Address(
CepID,
Street,
Number,
Location,
Complement,
Reference)Values
(
?,
?,
?,
?,
?,
?
)
INSERT INTO CustomerAddress(
AddressID,
CustomerID,
AddressTypeID,
TypeDescription) VALUES(
@@Identity,
?,
?,
?
)



what's the problem ??

View 7 Replies View Related







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