Adding Additional 'and' Information Into SQL Statement In Excecute SQL Task

May 29, 2008



I am using an execute SQL Task item on the control flow to be used as input for the foreach loop container. I have a select statement but, based on other information provided before this is executed, additional 'and' information may need to be added onto the SQL Statement before execution. For example, the select statement may read:

select applicatonid, created, createdby
from application
where referred by = 'xxx'

But based on information obtained from an ini file, something like:

and referred date = '2008/05/28'

may need to be appended to the SQL statement. I have tried setting the SQL statement as:

select applicatonid, created, createdby
from application
where referred by = 'xxx'

+ @addlwhere

and defined the @addlwhere in the parameter mapping but it raises an error. Has anyone run across this type of need and how did you resolve it? Thanks!

View 4 Replies


ADVERTISEMENT

(Urgent) Update Statement Takes For Ever To Excecute

Dec 4, 2007

Hi, i am trying to Update some records in my table but the update statement is taking for ever ...this is my update Statements
 UPDATE
Statements..ParticipantFundBalances
SET
Act1 = ACT_ID1,
TotAct1 = TOT_ACT1,
Act2 = ACT_ID2,
TotAct2 = TOT_ACT2,
Act3 = ACT_ID3,
TotAct3 = TOT_ACT3,
Act4 = ACT_ID4,
TotAct4 = TOT_ACT4,
Act5 = ACT_ID5,
TotAct5 = TOT_ACT5,
Act6 = ACT_ID6,
TotAct6 = TOT_ACT6,
Act7 = ACT_ID7,
TotAct7 = TOT_ACT7,
Act8 = ACT_ID8,
TotAct8 = TOT_ACT8,
Act9 = ACT_ID9,
TotAct9 = TOT_ACT9,
Act10 = ACT_ID10,
TotAct10 = TOT_ACT10,
Act11 = ACT_ID11,
TotAct11 = TOT_ACT11,
Act12 = ACT_ID12,
TotAct12 = TOT_ACT12,
Act13 = ACT_ID13,
TotAct13 = TOT_ACT13,
Act14 = ACT_ID14,
TotAct14 = TOT_ACT14,
Act15 = ACT_ID15,
TotAct15 = TOT_ACT15,
Act16 = ACT_ID16,
TotAct16 = TOT_ACT16,
Act17 = ACT_ID17,
TotAct17 = TOT_ACT17,
Act18 = ACT_ID18,
TotAct18 = TOT_ACT18,
/*Act19 = ACT_ID19,
TotAct19 = TOT_ACT19,
Act20 = ACT_ID20,
TotAct20 = TOT_ACT20, */
OpeningUnits = UNIT_OP,
OPricePerUnit = PRICE_OP,
ClosingUnits = UNIT_CL,
CPricePerUnit = PRICE_CL,
AllocationPercent = ALLOC_PER1

FROM
Statements..ParticipantFundBalances pfb
JOIN (
Select
cp.PlanId,
p.ParticipantId,
@PeriodId Period,
CASE WHEN a.FUND_ID = 'LOAN' Then 0 ELSEf.FundId END FundId,
a.ACT_ID1,
a.TOT_ACT1,
a.ACT_ID2,
a.TOT_ACT2,
a.ACT_ID3,
a.TOT_ACT3,
a.ACT_ID4,
a.TOT_ACT4,
a.ACT_ID5,
a.TOT_ACT5,
a.ACT_ID6,
a.TOT_ACT6,
a.ACT_ID7,
a.TOT_ACT7,
a.ACT_ID8,
a.TOT_ACT8,
a.ACT_ID9,
a.TOT_ACT9,
a.ACT_ID10,
a.TOT_ACT10,
a.ACT_ID11,
a.TOT_ACT11,
a.ACT_ID12,
a.TOT_ACT12,
a.ACT_ID13,
a.TOT_ACT13,
a.ACT_ID14,
a.TOT_ACT14,
a.ACT_ID15,
a.TOT_ACT15,
a.ACT_ID16,
a.TOT_ACT16,
a.ACT_ID17,
a.TOT_ACT17,
a.ACT_ID18,
a.TOT_ACT18,
/*a.ACT_ID19,
a.TOT_ACT19,
a.ACT_ID20,
a.TOT_ACT20, */
a.UNIT_OP,
a.PRICE_OP,
a.UNIT_CL,
a.PRICE_CL,
Cast(Rtrim(i.ALLOC_PER1) as decimal) as ALLOC_PER1
FROM
ASDBF a
-- Derive the unique PlanId from the Statements ClientPlan table
INNER JOIN Statements..ClientPlan cp
ON a.PLAN_NUM = cp.ClientPlanId
AND
cp.ClientId = @ClientId
-- Derive the unique ParticipantId from the Statements Participant table
INNER JOIN Statements..Participant p
ON a.PART_ID = p.PartId--Derive the unique FundID from the Statements Fund Table...Left Outer JOIN Statements..Fund f
ONa.FUND_ID = f.Cusip
OR
a.FUND_ID = f.Ticker
OR
a.FUND_ID = f.ClientFundId
-- get the allocation percent from the INVSRC
LEFT Outer JOIN INVSRC i
ONa.FUND_ID = i.INV_ID
AND
a.PLAN_NUM = i.Plan_Number
AND
a.PART_ID = i.PART_ID

WHERE
a.Import = 1
)a
ON pfb.PlanId = a.PlanId
AND
pfb.ParticipantId = a.ParticipantId
AND
pfb.PeriodId = PeriodId
AND
pfb.FundId = a.FundId
 
 
While i insert data in my table i am checking if there are any loans in the ASDBF table and if there i am inserting a 0 in the particular
i am trying to up date the with in 3 different plans in the same table..
 
any help will be appreciated.
Regards
Karen

View 1 Replies View Related

Excecute Package Task From BIDs:How To Stop Child Packages From Appearing In The Ide

Mar 21, 2007

Hi I have completed my first SSIS master package which runs a whole lot of child packages depending on value of expressions on workflow. (refer http://www.sqlis.com/306-3.aspx)

Each of my child packages is .dtsx file location and each Excute Package task uses the file connection.

The master parent package is also a dtsx file location which will be run by a SQL Server 2005 Agent

All good--problem is testing from BIDs--each time a Excecute package task is run--turns yellow a new tab appears apears in the design window --showing you that particular .dtsx file control flow detail. DTS never had this behaviour --can I turn this off in the BIDS ie as I have dozens of new tabs at run time which makes it very hard to keep track of the master package. All I want is the master package running from BIDs, and no new tabs appearing at run time???

Thanks kindly

Dave

View 4 Replies View Related

Why Additional Information: System Error.?

Dec 18, 2003

I have a DataGrid, it will return a table in SQL2000 server.

the problem is:

no data in the datagird, only a record "null" in all field.

I find a sample is add a "sqlDataAdapter1.Fill".

but if I add the code:

sqlDataAdapter1.Fill(dataSet21);

I got the error:

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

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

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

I have search this problem fix many many time, many people has this problem, looks like no result I can find.

Please help, thanks very very much.

Thanks.

View 2 Replies View Related

Extend GetUserID Function Or Create Additional Custom Information Funcitons

Jan 25, 2008

Hi there

I'm relatively new to Reporting Services and .Net development so bear with me if I've missed something obvious.
I've set up Reporting Services to run under forms authentication successfully.
I want to filter the data (both within Report Builder Models and .rdl files) to the company the user belongs to.

To avoid joining the users table to all other tables on the companyID I'm wondering if it's possible to create a custom funciton which could use the UserID to lookup the companyID and then pass this through as a parameter, and have this "GetCompanyID" function available when building Models and/or reports...???

When building a model the Information Functions available are GETUSERID and GETUSERCULTURE. Is it possible to modify how these work and/or create additional functions here???


Thanks in advance for your help.

Cheers,
Todd.

View 3 Replies View Related

Adding An Additional Database

Feb 28, 2001

Hi,

What are all the performance parameters to be analyzed, in an existing production server, to accommodate an additional database.

Regards
Kalyan

View 1 Replies View Related

Adding Additional Column

Feb 29, 2008

Hi All,

I have developed a report using report viewer in asp.net web form. The report is generated based on the selection of Department. User have an option to multi select the departments so the department column grows. Lets say user select Business category first and generate the report then user decides to add another department say Engineering. No the report column headers will have addional column "Engineering". I have used the Matrix since I had to group by Name and dates. Everything is good so far.
Now I have to add an additional column "Notes" at the end of all the columns. If there is ony department is chosen then Notes column appears after that and if mulitple departments are chosen the Notes column should also appear after all the department column (at the very end).
I am really having hard time to accomplish this. Is there any suggestion or solution to finish this? I really appreciate your responses.

Thank you.

View 1 Replies View Related

Adding Additional Fields To ASPNETDB.mdf

Dec 28, 2006

I am attempting to add additional fields and data to the default users database that is created as a result of enabling roles on my website.  Is it possible to add additional data fields to this file?  Where can I find the commands to do this?

View 2 Replies View Related

Recovery :: Adding Additional Listener To New DR Site

Sep 1, 2015

We have a server A and a server B setup with SQL2014 High Availability - working fine.

I need to add an additional listener to our new DR site (SQLNODECOLO). 

What is the best way to do this without impacting production?

Can I just go to server A and add the new listener server here (SQLNODECOLO):

View 4 Replies View Related

Fuzzy Lookup Error When Adding Additional Lookup Columns

Sep 26, 2007

I'm working with an existing package that uses the fuzzy lookup transform. The package is currently working; however, I need to add some columns to the lookup columns from the reference table that is being used.

It seems that I am hitting a memory threshold of some sort, as when I add 3 or 4 columns, the package works, but when I add 5 columns, the fuzzy lookup transform fails pre-execute:

Pre-Execute
Taking a snapshot of the reference table
Taking a snapshot of the reference table
Building Fuzzy Match Index
component "Fuzzy Lookup Existing Member" (8351) failed the pre-execute phase and returned error code 0x8007007A.

These errors occur regardless of what columns I am attempting to add to the lookup list.

I have tried setting the MaxMemoryUsage custom property of the transform to 0, and to explicit values that should be much more than enough to hold the fuzzy match index (the reference table is only about 3000 rows, and the entire table is stored in less than 2MB of disk space.

Any ideas on what else could be causing this?

View 4 Replies View Related

SQL 2012 :: Adding Header Information To XML Generated File

Apr 23, 2015

I have a sql query:

SELECT
'5' AS 'value/@version',
'database' AS 'value/@type',
'master' AS 'value/name',
LTRIM(RTRIM(( [Server Name] ))) AS 'value/server',
'True' AS 'value/integratedSecurity',
15 AS 'value/connectionTimeout',
4096 AS 'value/packetSize',
'False' AS 'value/encrypted',
'True' AS 'value/selected',
LTRIM(RTRIM(( [Server Name] ))) AS 'value/cserver'
FROM dbo.RedGateServerList
FOR XML PATH(''), ELEMENTS

I need to add some header information to the beginning of the query:

<?xml version="1.0" encoding="utf-16" standalone="yes"?><!--
SQL Multi Script 1
SQL Multi Script
Version:1.1.0.34--><multiScriptApplication version="2" type="multiScriptApplication"><databaseLists type="List_databaseList" version="1">

Everything I have tried ends up as a failure, usually compile issues. My goal here is to be able to automare a configuration file for multiscript so I can keep my server list up to date.

View 2 Replies View Related

Excecute SQL Script In Exrpess Edition

Jul 14, 2006

How to Excecute SQL Script in Exrpess edition?

I wanna create a database using a lot of SQL script, but I don't know how to use it just like I used to do in the Query Analyser of SQL Server 2000.

View 3 Replies View Related

Retrieving Form A Text Box And Using Information In SQL Statement

Mar 8, 2008

Hi everyone,
 So what I am trying to do is to have a simple textbox where the person enters a code.
 Then I need to have that code in an SQL statement like: SELECT Participant_Code FROM Contacts WHERE (this is where im stuck, I need to have something like WHERE Participant_code = code (code is the textbox ID))
 After this is done I need to keep this code from page to page, because I will need to add data from other textboxes to the database.
 Thanks

View 2 Replies View Related

Select Statement To Pull SQL Server Information

May 6, 2008

Sorry if this is rudimentary.

I need a select statement to retrieve what version of sql server is running and whether it is enterprise or standard.

I know I could just right click but I have hundreds of servers to go through so this should save alot of time.

Thanks,
Kraig

View 2 Replies View Related

Adding File Information To SQL Database On File Upload

Apr 18, 2004

Hi there :)

I'm in the final stage of my asp.net project and one of the last things I need to do is add the following file information to my SQL server 2000 database when a file is uploaded:

First of all I have a resource table to which I need to add:
- filename
- file_path
- file_size
(the resource_id has a auto increment value)

so that should hopefully be straight forward when the file is uploaded. The next step is to reference the new resource_id in my module_resource table. My module resource table consists of:
- resource_id (foreign key)
- module_id (foreign key)

So, adding the module_id is easy enough as I can just get the value using Request.QueryString["module_id"]. The bit that I am unsure about is how to insert the new resource_id from the resource table into the module_resource table on file upload. How is this done? Using one table would solve the issue but I want one resource to be available to all modules - many to many relationship.

Any ideas?

Many thanks :)

View 1 Replies View Related

Adding References To Script Task

Sep 24, 2006

How do you add a reference if the assembly you want to reference does not live in C:WindowsMicrosoft.NETFrameworkv2.0.50727? It doesn't seem to make sense that you cannot access the connections the AquireConnection() method serves since the interfaces are defined in Microsoft.SQLServer.DTSRuntimeWrap.dll (in C:Program FilesMicrosoft SQL Server90SDKAssemblies).

For example the code below works fine, in order to make it work I had to copy DTSRuntimeWrap.dll to v2.0.50727, surely any assembly which is been added to the GAC should be available as a referece?

Public Sub Main()

Dim cmgr As Microsoft.SqlServer.Dts.Runtime.ConnectionManager = Dts.Connections("FTP Connection Manager")

Dim cn As Object = cmgr.AcquireConnection(Nothing)

Dim ftpConnection As IDTSFtpClientConnection90

ftpConnection = TryCast(cn, IDTSFtpClientConnection90)

ftpConnection.Connect()

Dim folders As String()

Dim files As String()

ftpConnection.GetListing(folders, files)

ftpConnection.Close()

Dts.TaskResult = Dts.Results.Success

End Sub

View 4 Replies View Related

Adding Decimal Value During Data Flow Task

Nov 19, 2006

Hi,

I have a flat file(pipe delimited), like below( only two rows shown)

1|001|B|C|002|A|003|

1|005|D|C|003|A|004|

I have to import column 2( that is 001), column 5 (that is 002), column 7(that is 003) from the above flat file to column in Database that has DataType Numeric DataTyp (4,3).

In the Database the columns shoule have values like(.001), (.002), (.007). I have used flat file source, Script component, and OleDbDesitnation in my DataFlow task.

In the script component, I have added a "." for each column as a string.

I cannot import to OldeDbDestination becuase of Data conversion issue.

Is there any way we can solve this..

Thank you.







View 2 Replies View Related

Adding The Data Flow Task Programmatically

Aug 1, 2007

Is it possible to add a Fuzzy Grouping Transformation in a Data flow task by Programmatically ? If it possible, what is the C# or VB .net code for that ?

View 1 Replies View Related

Adding Expression In Data Flow Task

Oct 9, 2006

Hi

I am trying to develop a data flow task in C#. I need to add an expression tab in the task where i can write expressions on the input columns and map it to outputs. Please let me know how to go about it. I am new to SSIS coding so dnt have much idea abt it.

Thanks in advance,

Vipul

View 9 Replies View Related

Adding A Web Reference (web Service) To An SSIS Script Task?

Apr 5, 2007

Is it possible to do this under SSIS 2005? How? I see I can add a reference to system.web.services.dll.. but then what?



The web service was developed in vb.net/vs.net 2005 and I have no problem adding and consuming it from a web page developed using vs.net 2005 - asp.net/vb.net.



Thanks for any help or information.







View 3 Replies View Related

Adding Conditional Statement To A Sum

Jun 12, 2007

currently I am creating a total if the date is between two entered dates:

select sum(case when exigo_data_sync.orders.orderdate between @prevMonthStart and @prevMonthEnd then 1 else 0 end) as PrevMonthCount,

I need to check an additional column for ($1.00) or $1.00. If it contains $1.00 then proceed as normal and add to the total. If it contains ($1.00) then subtract one from the total. Any advice?

View 7 Replies View Related

Help With SQL If Statement And Adding Fields Together

Jul 23, 2005

I have a query that I need a hand on. I am trying to add togther somefiends based on values of another.What I would like to add a billing total by saying more or less thefollowing:SELECT labor_hours, labor_cost, expidite_fee, flat_rate,include_repair_cost, include_cal, include_flat_rate, include_parts,cur_bill,(labor_hours * labor_cost) AS labor_total,(ISNULL((SELECT TOP 1 cal_cost FROM calID WHERE orderID=79559 ORDER BYdateCAL DESC),0)) AS cal_total,(ISNULL((SELECT SUM((qty * cost) + premium_charge) AS gptotal FROMrepair_partsID WHERE orderID=79559),0) +ISNULL((SELECT SUM(qty_needed * cust_cost) AS gnptotal FROMmisc_part_assocID WHERE orderID=79559),0)) AS parts_total,((labor_hours * labor_cost) + expidite_fee + flat_rate +ISNULL((SELECT TOP 1 cal_cost FROM calID WHERE orderID=79559 ORDER BYdateCAL DESC),0) +ISNULL((SELECT SUM((qty * cost) + premium_charge) AS gptotal FROMrepair_partsID WHERE orderID=79559),0) +ISNULL((SELECT SUM(qty_needed * cust_cost) AS gnptotal FROMmisc_part_assocID WHERE orderID=79559),0)) AS actual_total,(expidite_feeIF include_repair_cost = 1+ (labor_hours * labor_cost)IF include_flat_rate = 1+ flat_rateIF include_cal = 1+ ISNULL((SELECT TOP 1 cal_cost FROM calID WHERE orderID=79559 ORDERBY dateCAL DESC),0)IF include_parts = 1+ ISNULL((SELECT SUM((qty * cost) + premium_charge) AS gptotal FROMrepair_partsID WHERE orderID=79559),0) +ISNULL((SELECT SUM(qty_needed * cust_cost) AS gnptotal FROMmisc_part_assocID WHERE orderID=79559),0)) AS billing_totalFROM view_inventoryWHERE orderID=79559I know the IF part is whacked, that's where I need the help. Is thistype of thing even possible? Or even efficent? Is it wise to subqueryfor totals (not like I have a choice based on the applicationrequirements)? help.

View 2 Replies View Related

Programmatically Adding A Script Component To Data Flow Task

Feb 2, 2007



Dear all,

I am developing tools for automatic creation of data warehouse tables, cubes and SSIS packages. Generating the SSIS Data Flows works very well using the SSIS components for OLE DB Source, Derived Column, Lookup and OLE DB Destination.

However for some of the advanced functionality I need to use Script Component. I have managed to add it in the Data Flow with all inputs and outputs, but how do I populate it with my code? I've seen there is a component property called "SourceCode" and one called "BinaryCode". The "SourceCode" contains the code, but also some extra metadata.

Questions:

Do you know if there is any programmatic support to generate the Source Code property with the metadata necessary?

Do you know how to compile the Source Code and generate the property BinaryCode?

Example from my code below:

// Create script component

IDTSComponentMetaData90 script = dataFlowTask.ComponentMetaDataCollection.New();

script.ComponentClassID = app.PipelineComponentInfos["Script Component"].CreationName;

CManagedComponentWrapper scriptWrapper = script.Instantiate();

script.InputCollection.New();

script.OutputCollection.New();

scriptWrapper.ProvideComponentProperties();

script.Name = "Logics";

// Create path

IDTSPath90 scriptPath = dataFlowTask.PathCollection.New();

scriptPath.AttachPathAndPropagateNotifications(lastComponent.OutputCollection[0], script.InputCollection[0]);

// Populate input and output columns

IDTSInput90 scriptInput = script.InputCollection[0];

IDTSVirtualInput90 scriptVInput = scriptInput.GetVirtualInput();

foreach (IDTSOutputColumn90 col in oledbSrc.OutputCollection[0].OutputColumnCollection)

{

scriptWrapper.SetUsageType(scriptInput.ID, scriptVInput, col.LineageID, DTSUsageType.UT_READONLY);

IDTSOutputColumn90 tmp = script.OutputCollection[0].OutputColumnCollection.New();

tmp.Name = col.Name;

tmp.SetDataTypeProperties(col.DataType, col.Length, col.Precision, col.Scale, col.CodePage);

}

// Make script asynchronous

script.OutputCollection[0].SynchronousInputID = 0;

Thanks for any assistance and Best Regards,

Johan Åhlén,
Business Intelligence consultant at IFS

View 2 Replies View Related

How To Read SQL Statement In T-SQL Statement Task?

Jun 7, 2007

hi all,



after convert from DTS to SSIS, how can i open the SQL statement? because i only saw a line in the properties of the task.



i open the DTSX in vs2005, but i can open to view the SQL statement.



in sql 2000 just double click on the SQL Task, then will popup a dialog form to show the SQL task.



please help.



thanks a lot

View 1 Replies View Related

SP Case Statement For Adding Innerjoin

Dec 4, 2006

I want to add an INNER JOIN based on a condition. If @Sports is not '' then I want to add the inner join statement...The following doesnt work:declare @Sports nvarchar(50)set @sports='1'
SELECT DISTINCT tblUserData.UserName,tblUserData.UserCode,Description,IsDonator,IsVIP,BirthDate,IsMale,ShowAgeOnly,tblCountries.CountryPicture,case @LanguageColumnName when 'nl' then tblSexuality.nl when 'en' then tblSexuality.en when 'de' then tblSexuality.deendas sexualityname,tblCountries.CountryName,ThumbNailPicture,UserRanking,LastActivityDate,NearestBigCity,DistanceToNearestBigCity,ROW_NUMBER() OVER (ORDER BY IsVip DESC,UserRanking DESC,LastActivityDate DESC) as RowNum FROM aspnet_UsersINNER JOIN tblUserData ON aspnet_Users.UserId = tblUserData.UserIDINNER JOIN tblCountries ON tblUserData.Country=tblCountries.CountryID INNER JOIN tblSexuality ON tblUserData.Sexuality=tblSexuality.SexualityID ,case @Sportswhen <>'' INNER JOIN tblUsersAndSports ON tblUserData.UserCode=tblUsersAndSports.UserCodeend

View 5 Replies View Related

Help On Adding Another Filter Statement On The Query

May 27, 2008

Hi everybody have this query that list all the duplicate records meaning the occurence of pubinfid in more than one row. This gets me fine. Iwant thought to insert a where clause that further filters the result where pubid between 30 and 33. I tried placing it after the FROM CLAUSE BUT DOESN'T GIVE me what I want it still includes records other than the between clause. Also I tried placing it after the HAVING clause but it includes records which has only one count.. Where could I place the where clause or is ther an alternative for this.



SELECT a.pubinfid, a.pubid, a.pubcount
FROM pubssubscribe AS a INNER JOIN
(SELECT pubinfid
FROM pubssubscribe
GROUP BY pubinfid
HAVING (COUNT(*) > 1)) AS b ON a.pubinfid = b.pubinfid



thanks

View 8 Replies View Related

Adding Groups In A Select Statement

Jul 8, 2014

The select statement below works fine but just to a limited extend.

There is just one table (prices) with 3 fields (ticker, close, date).

I use this select statement to get monthly returns for 1 ticker.

My question is: can I get this same statement for multiple tickers? I guess I have to group by ticker but I wouldn´t know how to do it.

--Get Monthly Returns As Percentage
WITH PriceMonthly_CTE
AS
(select
row_number() OVER (ORDER BY DATE_) AS Period,

[Code] .....

View 2 Replies View Related

Adding Column Values Together In SQL SELECT Statement

Aug 22, 2007

I have an SQL Select statement that I need to add a column to called SalePrice, the SalePrice column needs to be calculated by adding together the values of 12 columns, then multiplying that value by the value in a another column to calculate margin.  My issue is that I can only get it to add 7 column values together, if I add any more columns to the equation it just returns and null result.  My DB is SQL 2005 Express SP2.  My select statement is below:  SELECT dbo.MFG_DATA_Machines.ID, dbo.MFG_DATA_Machines.MachineName, dbo.MFG_DATA_Parts_CPU.PartDescription AS CPU,
dbo.MFG_DATA_Parts_CPU.PartCost AS CPUCost, dbo.MFG_DATA_Parts_Motherboard.PartDescription AS Motherboard,
dbo.MFG_DATA_Parts_Motherboard.PartCost AS MotherboardCost, dbo.MFG_DATA_Parts_RAM.PartDescription AS RAM,
dbo.MFG_DATA_Parts_RAM.PartCost AS RAMCost, dbo.MFG_DATA_Parts_HDD.PartDescription AS HDD,
dbo.MFG_DATA_Parts_HDD.PartCost AS HDDCost, dbo.MFG_DATA_Parts_OpticalDrive.PartDescription AS OpticalDrive,
dbo.MFG_DATA_Parts_OpticalDrive.PartCost AS OpticalDriveCost, dbo.MFG_DATA_Parts_Video.PartDescription AS Video,
dbo.MFG_DATA_Parts_Video.PartCost AS VideoCost, dbo.MFG_DATA_Parts_OS.PartDescription AS OS, dbo.MFG_DATA_Parts_OS.PartCost AS OSCost,
dbo.MFG_DATA_Parts_Modem.PartDescription AS Modem, dbo.MFG_DATA_Parts_Modem.PartCost AS ModemCost,
dbo.MFG_DATA_Parts_FloppyDrive.PartDescription AS FloppyDrive, dbo.MFG_DATA_Parts_FloppyDrive.PartCost AS FloppyDriveCost,
dbo.MFG_DATA_Parts_CardReader.PartDescription AS CardReader, dbo.MFG_DATA_Parts_CardReader.PartCost AS CardReaderCost,
dbo.MFG_DATA_Parts_PowerSupply.PartDescription AS PowerSupply, dbo.MFG_DATA_Parts_PowerSupply.PartCost AS PowerSupplyCost,
dbo.MFG_DATA_Parts_CaseType.PartDescription AS CaseType, dbo.MFG_DATA_Parts_CaseType.PartCost AS CaseTypeCost,
dbo.MFG_DATA_Machines.Notes, dbo.MFG_DATA_Machines.MarginPercent, dbo.MFG_DATA_Machines.PriceOverride,
(dbo.MFG_DATA_Parts_CPU.PartCost + dbo.MFG_DATA_Parts_Motherboard.PartCost + dbo.MFG_DATA_Parts_RAM.PartCost + dbo.MFG_DATA_Parts_HDD.PartCost
+ dbo.MFG_DATA_Parts_OpticalDrive.PartCost + dbo.MFG_DATA_Parts_Video.PartCost + dbo.MFG_DATA_Parts_OS.PartCost + dbo.MFG_DATA_Parts_Modem.PartCost
+ dbo.MFG_DATA_Parts_FloppyDrive.PartCost + dbo.MFG_DATA_Parts_CardReader.PartCost + dbo.MFG_DATA_Parts_PowerSupply.PartCost + dbo.MFG_DATA_Parts_CaseType.PartCost)
* ((dbo.MFG_DATA_Machines.MarginPercent + 100) / 100) AS SalePrice
FROM dbo.MFG_DATA_Machines LEFT OUTER JOIN
dbo.MFG_DATA_Parts_CaseType ON dbo.MFG_DATA_Machines.CaseType = dbo.MFG_DATA_Parts_CaseType.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_Motherboard ON dbo.MFG_DATA_Machines.Motherboard = dbo.MFG_DATA_Parts_Motherboard.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_Video ON dbo.MFG_DATA_Machines.Video = dbo.MFG_DATA_Parts_Video.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_RAM ON dbo.MFG_DATA_Machines.RAM = dbo.MFG_DATA_Parts_RAM.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_PowerSupply ON dbo.MFG_DATA_Machines.PowerSupply = dbo.MFG_DATA_Parts_PowerSupply.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_OS ON dbo.MFG_DATA_Machines.OS = dbo.MFG_DATA_Parts_OS.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_OpticalDrive ON dbo.MFG_DATA_Machines.OpticalDrive = dbo.MFG_DATA_Parts_OpticalDrive.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_Modem ON dbo.MFG_DATA_Machines.Modem = dbo.MFG_DATA_Parts_Modem.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_HDD ON dbo.MFG_DATA_Machines.HardDisk = dbo.MFG_DATA_Parts_HDD.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_FloppyDrive ON dbo.MFG_DATA_Machines.FloppyDrive = dbo.MFG_DATA_Parts_FloppyDrive.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_CPU ON dbo.MFG_DATA_Machines.CPU = dbo.MFG_DATA_Parts_CPU.ID LEFT OUTER JOIN
dbo.MFG_DATA_Parts_CardReader ON dbo.MFG_DATA_Machines.CardReader = dbo.MFG_DATA_Parts_CardReader.ID  

View 2 Replies View Related

Adding Case Statement To Existing Query

Apr 3, 2008

I was asked to add an additional column to an existing query. I'm using Microsoft Query with a MS SQL 2000 server, and don't have much knowledge of SQL in general. Here's the existing query:



SELECT A.COMPANYCODE,
A.INVOICENUMBER,
A.LINENUMBER,
A.SONUMBER,
A.CUSTOMERCODE,
A.SHIPPERNUMBER,
A.INVOICEDATE,
A.ITEMCODE,
A.QUANTITYINVOICED,
A.UNITPRICE AS 'InvPrice',
A.QUANTITYINVOICED * A.UNITPRICE AS 'ExtInvPrice',
INVENTORY.UNITPRICE AS 'StdPrice',
INVENTORY.STANDARDCOST,
A.QUANTITYINVOICED * INVENTORY.STANDARDCOST AS 'ExtCost',
(A.QUANTITYINVOICED * A.UNITPRICE) - (A.QUANTITYINVOICED * INVENTORY.STANDARDCOST) AS 'GM$',
(INVENTORY.UNITPRICE - A.UNITPRICE) * -1 AS 'PriceListDiff'
FROM ABW.DBO.SALESANALYSISHISTORY A,
ABW.DBO.INVENTORY INVENTORY
WHERE INVENTORY.COMPANYCODE = A.COMPANYCODE
AND INVENTORY.ITEMCODE = A.ITEMCODE
AND ((A.COMPANYCODE = 'csp')
AND (A.QUANTITYINVOICED <>$ 0)
AND (A.INVOICEDATE BETWEEN '03/1/08' AND '03/31/08'))
ORDER BY A.INVOICEDATE,
A.ITEMCODE



They want a column added to the current query where if A.Unitprice is greater than or equal to Inventory.UnitPrice then populate the column with A.QuantityInvoiced*A.UnitPrice. I posted on another forum, and the advice I got was to add this:


SELECT NewColumn = CASE
WHEN A.Unitprice >= Inventory.UnitPrice THEN A.QuantityInvoiced * A.Unitprice
ELSE 'null'
END,
FROM ABW.DBO.SALESANALYSISHISTORY A,
ABW.DBO.INVENTORY INVENTORY

I'm not sure how to integrate it to the current query, so I've tried running it by itself, and I get the error: Didn't expect 'A' after the SELECT column list.

Any help would be greatly appreciated to modify the current query to display the new column.

View 2 Replies View Related

SQL Statement, Adding Two COUNT/CASE Statements

Dec 12, 2007



SELECT COUNT(DISTINCT CASE WHEN visit_type = 0 THEN visitor_id END) AS [New Visitors],
COUNT(DISTINCT CASE WHEN visit_type = 0 THEN visitor_id END) AS [Returning Visitors]
FROM content_hits_tbl
WHERE (hit_date BETWEEN DATEADD(mm, - 1, GETDATE()) AND GETDATE())

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

How do I add up both COUNT/CASE columns? Would it be:
SUM([New Visitors] + [Returning Visitors]) AS Total


I tried this and it doesn't work. I get invalid column names error for both.

I have even tried:
SUM([COUNT(DISTINCT CASE WHEN visit_type = 0 THEN visitor_id END)] + [COUNT(DISTINCT CASE WHEN visit_type = 0 THEN visitor_id END)]) AS Total

You would think that there would be some gui functionality in VS08 that would do this...


Thoughts are greatly appreciated!

TT

View 8 Replies View Related

Integration Services :: Adding Values To A Drop Down List In Custom SSIS Task

May 12, 2015

I am writing my first custom SSIS task and I can see that, if I put a public property into the task, I see that property in the standard Properties window. If I add a property of type String, I can put a value in that property, in the task code, and when I instantiate the task in a package, I can see the value I entered.

To try and get a drop down list property in the Properties window, I declared a property of type Combobox, and indeed a drop down list appears in that property.

My problem is trying to get values in that property. I have used the test items:

    Property.Items.add("Fred")
    Property.Items.Add("Jim")

But I do not see the values in the drop down list. All I do see is one item with a value of "(none)".

View 3 Replies View Related

Integration Services :: SSIS Script Task - Adding Dataset File To Runtime Folder

Aug 17, 2015

I have an SSIS script task using c#. i need to refere an .xsd dataset in the c# code. i tried to set property below.Build action to Content or Compile Copy to output directory Copy always But still i m unable to use the dataset in my code.

View 4 Replies View Related

SQL Server 2014 :: Adding One More Column For SubTotal In Select Statement?

Feb 13, 2014

We have a table with 2 columns 'OrderNo' and 'Amount' as below

ORDERNO | AMOUNT
1D1ZX000 | 9262.5
1D1ZX001 | 9000.0
1D1ZX001 | 9000.0
1D1ZX002 | 10000
1D1ZX003 | 1000
1D1ZX003 | 200.50
1D1ZX003 | 100.50
1D1ZX004 | 500.0
1D1ZX004 | 1000
1D1ZX004 | 2000
1D1ZX004 | 1000

as per my client requirement we need subtotal of 'Amount' group by 'OrderNo'. column so am writing a select statement with WHERE condition and I would like to have another column called SUBTOTAL in the result set (select statement result) with subtotals for that order Number as below

ORDERNO | AMOUNT | SubTotal
1D1ZX000 | 9262.5 | 9262.5
1D1ZX001 | 9000.0 | 18000
1D1ZX001 | 9000.0 | 18000
1D1ZX002 | 10000 | 10000
1D1ZX003 | 1000.0 | 3001
1D1ZX003 | 2000.5 | 3001
1D1ZX003 | 1000.5 | 3001
1D1ZX004 | 500.00 | 4500
1D1ZX004 | 1000.0 | 4500
1D1ZX004 | 2000.0 | 4500
1D1ZX004 | 1000.0 | 4500

View 7 Replies View Related







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