Error 3105 While Writing

Jun 6, 2001

When I am writing a numerous number of records to an sql 2000 db from a single "large" *.dbf I eventually get an error, error code 3105 from the ole
db provider for sql (Error Description: The requested properties cannot be supported), after about 400 or so records are written. I monitored
what commands the sql server is doing and this is where is gives me an error:

(previous command from sql monitor for reference)
declare @P1 int
set @P1=180150371 <-------- p1 gets incremented by one every consecutive time I write something to the db
declare @P2 int
set @P2=2 <-------------- same as all previous writes
declare @P3 int
set @P3=4 <-------------- same as all previous writes
declare @P4 int
set @P4=-1 <-------------- same as all previous writes
exec sp_cursoropen @P1 output, N'SELECT UUT_NUM,SEQ_RESULT, (etc...), @P2 output, @P3 output,
@P4 output
select @P1, @P2, @P3, @P4

(this is where the error is)
declare @P1 int
set @P1=0
declare @P2 int
set @P2=229378
declare @P3 int
set @P3=294916
declare @P4 int
set @P4=0
exec sp_cursoropen @P1 output, N'SELECT UUT_NUM,SEQ_RESULT,(etc...),@P2 output, @P3 output, @P4 output
select @P1, @P2, @P3, @P4

It appears as though the P1 counter is reset to 0 for some reason and the other variables are not assigned the same value as all previous
times the write command was executed.
Does anyone know why this occurs? and why this gives me an error?

View 2 Replies


ADVERTISEMENT

BCP Not Writing To Error Log

Nov 29, 2007



Hi,

I'm trying to capture errors when executing my BCP to stop my batch job from continuing on to the the next steps.

Here's the syntax of my bcp

bcp TestDB.dbo.bcp_load in "C: estfile.csv" -S testserver -e "C:Logserror.log" -T -t , -c

I deliberately altered my file to force an error. The error that I'm trying to trap is

SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file
0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1

Instead of writing the error to C:Logserror.log, it is being generated in my dos prompt.

I cannot use attribute -o as it will write everything in the log including non-errors. What am I missing in my bcp and why is it not writing to my errorlog? HELP!

Thanks

View 3 Replies View Related

ERROR When Writing To The Database

Apr 25, 2005

Hi
i get the following error whe writing to the db, what does it mean?
System.Data.SqlClient.SqlException: An explicit value for the identity column in table 'tbl_StudentInfo' can only be specified when a column list is used and IDENTITY_INSERT is ON. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.Applicationform2_aspx.populateDb() in http://localhost/iris/Applicationform2.aspx:line 84

i am using the following code:

mycon.Open();

//string qry="insert into tbl_StudentInfo values ('"+Request.QueryString["Id"].ToString()+"','"+Request.QueryString["nam"].ToString()+"','"+Request.QueryString["surNa"].ToString()+"','"+Request.QueryString["DOB"].ToString()+"','"+Request.QueryString["addr"].ToString()+"','"+Request.QueryString["pCode"].ToString()+"','"+Request.QueryString["Cntry"].ToString()+"','"+Request.QueryString["email"].ToString()+"','"+Request.QueryString["ph"].ToString()+"','"+qualification+"','"+stdGPA+"','"+stdYear+"','"+Institute.Text+"','"+Tof.Text+"','"+subject+"','"+prrof.Text+"','"+""+"','"+todayDate+"')" ;
string qry="insert into tbl_StudentInfo values ('"+Request.QueryString["Id"].ToString()+"','"+Request.QueryString["nam"].ToString()+"','"+Request.QueryString["surNa"].ToString()+"','"+Request.QueryString["DOB"].ToString()+"','"+Request.QueryString["addr"].ToString()+"','"+Request.QueryString["pCode"].ToString()+"','"+Request.QueryString["Cntry"].ToString()+"','"+Request.QueryString["email"].ToString()+"','"+Request.QueryString["ph"].ToString()+"','"+qualification+"','"+stdGPA+"','"+stdYear+"','"+Institute.Text+"','"+Tof.Text+"','"+subject+"','"+prrof.Text+"','"+""+"','"+todayDate+"','"+RequestYear+"','"+""+"','"+""+"','"+"0"+"')" ;
myCommand = new SqlCommand(qry,mycon);
myCommand.ExecuteNonQuery();Response.Redirect("main.aspx");
}
catch(Exception e)
{
Response.Write(""+e);
}
the red line is line 84
PLEASE HELP

View 1 Replies View Related

Writing Error To The Windows Event Log

Feb 13, 2007

Hi,

I am developing a package that will be run by a master package. The main task of this package is to write the errorid, errordescription and other details passed by the master package to various destination like a text file, a sql server or an event log.

I am using the flat file and the OLEDB destination for the text file and sql server. But I could not find any destination component that will help to write to an event log. Do I have to write a destination custom component for this?

I will then use this package in the event handler at the package level. Also comment on my approach.

Thanks in advance for your help and time.

Regards,

$wapnil

View 2 Replies View Related

Error In Writing Condition In Complex Query

Apr 4, 2015

following is a working code

declare @dte as datetime='2015-04-01'
declare @StDt as Datetime = DATEADD(mm,DATEDIFF(mm,0,@dte), 0)
declare @EnDt as datetime = DATEADD( DD, -1, DATEADD(mm,DATEDIFF(mm,0,@dte) + 1, 0));
DECLARE @query AS NVARCHAR(MAX);

[code]...

iam getting the ouput correctly my requirement is i want to write a condition here
JOIN busdetails b ON m.bus_id = b.bus_id
i want to write this statement as
JOIN busdetails b ON m.bus_id = b.bus_id and m.uname='lekshmi'

when i tried this code iam getting error

View 1 Replies View Related

Error Writing To UserVariable In ScriptComponent In DataFlow

Oct 23, 2007



I have an SSIS Packaget that worked a month ago and when I ran it today it didn't work. It's failing in the ScriptComponent in a DataFlow that I created as a Destination. The only thing the script does is record any value for a particular column and on the PostExecute method, writes the last instance of that column to a user variable in the Package. Here's the code. There is a string variable that I use to hold the column's value for each row received.



Public Class ScriptMain

Inherits UserComponent


Dim s_remit_addr As String


Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)


Me.s_remit_addr = Row.remitaddr.ToString()

End Sub


Public Overrides Sub PostExecute()


Dim variables As Variables


Variables.gsremitaddr = Me.s_remit_addr

MyBase.PostExecute()

End Sub



It will always bomb in PostExecute with the error that the variable User::gs_remit_addr is not the same type as the variable I'm using (s_remit_addr); HOWEVER, the user variable is of type String and it worked a month ago. Does anyone have any idea how I can fix it?

View 3 Replies View Related

Writing ETL Error Records To A Common Table

Jun 13, 2007

I am working on building a template/design pattern for a DTS to SSIS upgrade project.



During our ETL processing, if we encounter a record that cannot be inserted into a destination table, we'd like to be able to write the entire record out to a common error/reject table. The obvious problem is that every SSIS package that is using this template will of course be dealing with varying table schemas.



I was thinking that if there were a way that I could transform the error record/buffer row into XML, I could then achieve my goal of having a common table to receive errors/rejects.



Has anyone done something like this, or have suggestions on how we might accomplish?



View 7 Replies View Related

Remote Connection Error : Problem In Writing In A Table

Feb 15, 2008

Hi,
I have a problem when updating tables in a SQL Server 2000. I am able to make a select form tables but I can't insert data. I got this error :
An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
SQLExpress database file auto-creation error:

View 3 Replies View Related

Error When Writing To SQL Server Through Asp Page Using Windows Authentication

Jul 20, 2005

I have an asp drive web page that writes a row to a table on sqlserver 2000. The web site is set to use windows authenication and thesql server is set to use windows authentication.This process works fine on windows xp sp 1 machines but on win2k sp4machines logged in as the same user i get the errorAn error occurred making the change -2147217843 Error connection toSQL Server: [Microsoft][ODBC SQL Server Driver][SQL Server]Loginfailed for user '(null)'. Reason: Not associated with a trusted SQLServer connection.can anyone explain why win2k client would have this issue and notwinxp clients?Glenn

View 1 Replies View Related

Fatal Network Error 4014 When Writing Big BLOB Chunks

Jun 1, 2007

Using the SqlClient provider I'm trying to write big datachunks of maybe 20 MB each to SQL server to store in BLOBs using blobColumn.Write(...) using .NET 2.0 dbcommand object calling a Stored procedure



CREATE PROCEDURE [dbo].[putBlobByPK]

(

@id dKey

, @value VARBINARY(MAX)

, @offset bigint

, @length bigint

, @ModDttm dModDttm OUT

, @ModUser dModUser OUT

, @ModClient dModClient OUT

, @ModAppl dModAppl OUT

)

....



When doing this I can do this exactly 3 times than the application hangs (for ever).



When looking in the SQL Server log, I find the following to errors:



Error: 4014, Severity: 20, Status: 2.



A fatal error occurred while reading the input stream from the network. The session will be terminated.



I don't get this error on the client! OK, the session died.



What may be the problem?



I write big chunks like this to avoid many writes as the data shall be replicated later using peer to peer replication. And the more writes used for writing the total BLOB the more huge becomes the transaction log of the subscriber database.



TIA



Hannoman

View 1 Replies View Related

Error Writing Data To Same Destination In Single Data Flow

May 12, 2006

I am getting the following error running a data flow that splits the input data into multiple streams and writes the results of each stream to the same destination table:

"This operation conflicts with another pending operation on this transaction. The operation failed."

The flow starts with a single source table with one row per student and multiple scores for that student. It does a few lookups and then splits the stream (using Multicast) in several layers, ultimately generating 25 destinations (one for each score to be recorded), all going to the same table (like a fact table). This all is running under a transaction at the package level, which is distributed to a separate machine.

Apparently, I cannot have all of these streams inserting data into the same table at one time. I don't understand why not. In an OLTP system, many transactions are inserting records into the same table at once. Why can't I do that within the same transaction?

I suppose I can use a UnionAll to join them back together before writing to a single destination, but that seems like an unnecessary waste and clutters the flow. Can anyone offer a different solution or a reason why this fails in the first place?

Thanks in advance.

View 3 Replies View Related

Enable Error Handling When Writing Custom Source Component /custom Error Handling Component.

Apr 21, 2006

1) We are writing a custome Source component for Oracle with OCI calls, Could some one please let me know how to Enable Error Handling for the Same,

2) Is it possible to write Custome Error Handeling Component for SSIS? if yes could you please help me on how to write it.

Thanks in advance.

View 1 Replies View Related

New To Writing In SQL

Jun 21, 2008

I have some experience with MS SQL mostly installation, configuration, maintaining, etc. But I am trying to teach myself some TSQL. I have bought a few beginner books and have some test machines. In advance, I appreciate any feedback!

I have a database with two tables. I want to calc the min salary for a class of employees. The "wage" is in one table and the "status" is in another.

USE Database
GO
SELECT MIN(Wage) AS "Min Salary", Status
FROM Employee, Job
WHERE Status = '1'
GROUP BY Wage, Status
GO

The result set brings back all not the "status" class that I want.

Again, I am relatively new so take it easy on me!

Thanks,
grinch

View 4 Replies View Related

Writing To SQL Log

Mar 3, 2008



Hello,

I wrote a stored procedure in SQL 2K5, and I would like to write to the sql log without using a rasieerror function. I just would like to log the sucessfull steps without exiting the proc. I am not sure how to do this. Any help would be appreciated.

Thanks,

Dave

View 3 Replies View Related

Writing To SQL

May 13, 2007

Hi,



I am new to this programming and SQL.



I am following the: Lesson 8: Obtaining Data from a SQL Server 2005 Express Edition Database video series. I cannot get the following to write changes to the SQL Database:



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

BindingSource1.EndEdit()

'CustomerTableAdapter1.Update(MyCompanyDataSet1.Customer)

Dim rowsAffected As Integer = 0

rowsAffected = CustomerTableAdapter1.Update(MyCompanyDataSet1.Customer)

MessageBox.Show(rowsAffected.ToString())

End Sub

End Class





I do get the message box to popup showing 1 row of changes when I make one change, however that change does not get written to the database. Is this enough info to have any idea why?





Thanks

View 1 Replies View Related

Writing SQL Statement

May 17, 2007

I was hoping that someone might be able to help a SQL statement for this, if possible.  I have two tables, InvoiceDetails and InvoiceLineItems.  What I'd like to do is write a query that will return all invoices, but also return a value InvoiceTotal Based on SUM(InvoiceLineItems.qty  * InvoiceLineItems.unitPrice).  I've tried a few different methods of writing this, but haven't had much luck.  Can anyone shed some light on this for me?  Thanks. 

View 7 Replies View Related

Help Writing The SqlConnectionString.

Dec 20, 2007

Hi.I realize this may have been asked a thousand times before, but it's still not working for me. I would appreciate any help with it. First, I created a GridView, and from it I created a new SqlDataSource and let it point to the database in C:My ProjectApp_DataASPNETDB.MDF. This automatically created a connectionString in the Web.Config file, saying the following:  "R1ASPNETDBConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename="C:My ProjectApp_DataASPNETDB.MDF";Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />  Now when I try to programatically use that connection string, the program crashes.    Below is my code: <script runat="server"> String sqlConnectionString = @"Data Source=.SQLEXPRESS;AttachDbFilename="C:My ProjectApp_DataASPNETDB.MDF";Integrated Security=True;Connect Timeout=30;User Instance=True";

protected void Page_Load(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { conn.Open(); const String selectQuery = "SELECT StatusName FROM Status ORDER BY StatusName"; Label1.Text = ""; using (SqlCommand cmd = new SqlCommand(selectQuery, conn)) { SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Label1.Text += dr[0]; while (dr.Read()) { Label1.Text += ", "; Label1.Text += dr[0]; } Label1.Text += ". "; } else
Label1.Text = "None."; } if (conn != null) conn.Close(); } }    Here's the error message I'm getting: Server Error in '/My Project' Application.

Keyword not supported: 'c:my projectapp_dataaspnetdb.mdf&quot;;integrated security'.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported: 'c:my projectapp_dataaspnetdb.mdf&quot;;integrated security'.

Source Error:




Line 15: protected void Page_Load(object sender, EventArgs e)Line 16: {Line 17: using (SqlConnection conn = new SqlConnection(sqlConnectionString))Line 18: {Line 19: conn.Open();







Source File: c:My Project est.aspx    Line: 17


Stack Trace:




[ArgumentException: Keyword not supported: 'c:my projectapp_dataaspnetdb.mdf&quot;;integrated security'.] System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +417 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +99 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +52 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +25 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +141 System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +38 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4 System.Data.SqlClient.SqlConnection..ctor(String connectionString) +21 ASP.test_aspx.Page_Load(Object sender, EventArgs e) in c:My Project est.aspx:17 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45 System.Web.UI.Control.OnLoad(EventArgs e) +80 System.Web.UI.Control.LoadRecursive() +49 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745   My question is: How should I write the connection string? I have a feeling the problem is with the quotes (&quot;), but I can't figure out how to write it otherwise.Thank you very much.

View 2 Replies View Related

Need Help On Writing A Query

Jan 22, 2008

Hello, I have two tables: Customer Training Requests has say two columns.Customer    -   Class Requested a                        1b                        1c                        1a                        2b                        2c                        3a                        3 I have another table called packages, which has packages of class.Package No.        Class1                            11                            2 I want to write a query which will return only those customers who have requested exactly the classes in a particular package.so in above example if the package is 1 the query should return only customer b as only customer b has requested class 1 and 2. Any suggestions? Thanks,Paresh.     

View 8 Replies View Related

Writing To Database

Feb 4, 2008

 hi, I'm trying to write to a database from a web page. The code is throwing back no errors but it just isn't writing to the database. Am I missing something? void SubmitDetails(Object s, EventArgs e)    {        SqlConnection objConn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);        SqlCommand objCmd;                objCmd = new SqlCommand(            "INSERT INTO Member_Information (Name, Address_Line_1, Address_Line_2, Address_Line_3, Email_Address, Contact_Number, " +            "Password, Name_Of_Bank, Account_Number, Sort_Code, Bank_Address_Line_1, Bank_Address_Line_2, Bank_Address_Line_3) " +            "VALUES (@Name, @Address_Line_1, @Address_Line_2, @Address_Line_3, @Email_Address, @Contact_Number, " +            "@Password, @Name_Of_Bank, @Account_Number, @Sort_Code, @Bank_Address_Line_1, @Bank_Address_Line_2, @Bank_Address_Line_3)", objConn);        objCmd.Parameters.AddWithValue("@Name", txtName.Text);        objCmd.Parameters.AddWithValue("@Address_Line_1", txtAL1.Text);        objCmd.Parameters.AddWithValue("@Address_Line_2", txtAL2.Text);        objCmd.Parameters.AddWithValue("@Address_Line_3", txtAL3.Text);        objCmd.Parameters.AddWithValue("@Email_Address", txtEmail.Text);        objCmd.Parameters.AddWithValue("@Contact_Number", txtContact.Text);        objCmd.Parameters.AddWithValue("@Password", txtPassword.Text);        objCmd.Parameters.AddWithValue("Name_Of_Bank", txtBank.Text);        objCmd.Parameters.AddWithValue("Account_Number", txtAN.Text);        objCmd.Parameters.AddWithValue("@Sort_Code", txtSort.Text);        objCmd.Parameters.AddWithValue("@Bank_Address_Line_1", txtBA1.Text);        objCmd.Parameters.AddWithValue("@Bank_Address_Line_2", txtBA2.Text);        objCmd.Parameters.AddWithValue("@Bank_Address_Line_3", txtBA3.Text);        objConn.Open();        objCmd.ExecuteNonQuery();        objConn.Close();    }   

View 4 Replies View Related

Help Writing Sql Query

Feb 23, 2008

Hello, how can do the following using sql:
 if exists(select * from siteindex where site_url like '%msn.com')ThenUpdate siteindex Set dmodified = GetDate(), isFullPage = 0, fp_flname = 'filename', fp_iWidth = 800, fp_iheight = 600
Where site_url = '%msn.com'
else
insert into siteindex (site_url, dcreated, dmodified, isFullPage, fp_flname, fp_iWidth, fp_iHeight)
Values ('msn.com', GetDate(), GetDate(), 0, 'filename', 800, 600)
 I cant get the syntax right.  Thanks!

View 1 Replies View Related

Sql Query Writing

Apr 28, 2008

Hi all,
        I have a problem with retrieving data from lookup tables. Ok here is the issue I have a Tables ... 
Tables  |     Schools                                      StuAccount
Fields   |     Sch_Id (pk)                                 Student_ID (pk)
                  School_Name                             AccountableSch_Id
                   DistrictName                             TestedSch_Id
                                                                    ParticipatedSch_Id
Ok, so i have two tables Schools and StuAccount, each has one primary key and and the StuAccount has three foreign keys that associates to the Schools TABLE which has a the definition of school names wich i want to retrieve for all three foreign key in the stuaccount table. Here is what i want ....
Student_ID 
AccountableSch_Id 
Shool_Name( this the name of the AccountableSch_Id )
TestedSch_Id
Shool_Name( this the name of the TestedSch_Id)
ParticipatedSch_Id
Shool_Name( this the name of the  ParticipatedSch_Id)
 I just want to look up the id and put the school name in the final resulting join and i have no idea how to lookup the table School three time and put school name for all three foreign keys.??
Any help will be much appreciated.
Thanks
 

View 4 Replies View Related

Help Writing SQL Statements

Jun 5, 2008

Hey everyone,
  I'm making a site and I need to write some code that will do the following things: 


Write a statement for the Page_Load event to pull the information from the db and load it into a textbox and a textbox with multiline attribute.

View 13 Replies View Related

Need Help Writing A Trigger

Nov 20, 2003

Please find the necessary SQL scripts to generate a small version of my database and some data at the bottom of this post.

Here's a short description of what the database is all about: It's a project tracking and management system. Contracts go into the tblDeals table. Because each project may be different in nature, project phases are defined in tblPhaseType and tblPhase tables. The table used to keep track of what's going on is the tblProduction table.

Here's what I need to do. When a project is completed -- meaning it has gone through all the phases that it needs to go through -- I want a trigger to fire up and change the contract status in the tblDeals table to "Completed" whose value is 1. When a new contract gets entered into the table, the Contract Status is set to 5 by default which means "In Progress" -- as defined in tblContractStatus. The tricky part is that because, each project is different and has different number of phases, the trigger has to make sure that all the phases have been submitted into the tblProduction table for that particular deal.

I'd really appreciate some help here. Thanks in advance for all your help.

---------------------------------------
Here's the script
---------------------------------------

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblDeals_tblCompany]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblDeals] DROP CONSTRAINT FK_tblDeals_tblCompany
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblDeals_tblContractStatus]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblDeals] DROP CONSTRAINT FK_tblDeals_tblContractStatus
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblDeals_tblPhaseType]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblDeals] DROP CONSTRAINT FK_tblDeals_tblPhaseType
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblPhase_tblPhaseType]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblPhase] DROP CONSTRAINT FK_tblPhase_tblPhaseType
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblProduction_tblDeals]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblProduction] DROP CONSTRAINT FK_tblProduction_tblDeals
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_tblProduction_tblPhase]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[tblProduction] DROP CONSTRAINT FK_tblProduction_tblPhase
GO

/****** Object: Table [dbo].[tblProduction] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblProduction]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblProduction]
GO

/****** Object: Table [dbo].[tblDeals] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblDeals]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblDeals]
GO

/****** Object: Table [dbo].[tblPhase] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblPhase]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblPhase]
GO

/****** Object: Table [dbo].[tblCompany] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblCompany]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblCompany]
GO

/****** Object: Table [dbo].[tblContractStatus] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblContractStatus]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblContractStatus]
GO

/****** Object: Table [dbo].[tblPhaseType] Script Date: 11/20/2003 11:30:48 AM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblPhaseType]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblPhaseType]
GO

/****** Object: Table [dbo].[tblCompany] Script Date: 11/20/2003 11:30:50 AM ******/
CREATE TABLE [dbo].[tblCompany] (
[CompanyID] [int] IDENTITY (1, 1) NOT NULL ,
[CompanyName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO

/****** Object: Table [dbo].[tblContractStatus] Script Date: 11/20/2003 11:30:50 AM ******/
CREATE TABLE [dbo].[tblContractStatus] (
[StatusID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[Status] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO

/****** Object: Table [dbo].[tblPhaseType] Script Date: 11/20/2003 11:30:51 AM ******/
CREATE TABLE [dbo].[tblPhaseType] (
[PhaseTypeID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[Desription] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO

/****** Object: Table [dbo].[tblDeals] Script Date: 11/20/2003 11:30:51 AM ******/
CREATE TABLE [dbo].[tblDeals] (
[DealID] [int] IDENTITY (1, 1) NOT NULL ,
[CompanyID] [int] NOT NULL ,
[DealDate] [smalldatetime] NOT NULL ,
[PhaseTypeID] [tinyint] NOT NULL ,
[CashAmount] [smallmoney] NOT NULL ,
[StatusID] [tinyint] NOT NULL
) ON [PRIMARY]
GO

/****** Object: Table [dbo].[tblPhase] Script Date: 11/20/2003 11:30:52 AM ******/
CREATE TABLE [dbo].[tblPhase] (
[PhaseID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[PhaseTypeID] [tinyint] NOT NULL ,
[PhaseDescription] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[PhasePercentage] [float] NOT NULL
) ON [PRIMARY]
GO

/****** Object: Table [dbo].[tblProduction] Script Date: 11/20/2003 11:30:52 AM ******/
CREATE TABLE [dbo].[tblProduction] (
[TransactionID] [int] IDENTITY (1, 1) NOT NULL ,
[DealID] [int] NOT NULL ,
[PhaseID] [tinyint] NOT NULL ,
[TransactionTimeStamp] [smalldatetime] NOT NULL ,
[Comments] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblCompany] WITH NOCHECK ADD
CONSTRAINT [PK_tblCompany] PRIMARY KEY CLUSTERED
(
[CompanyID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblContractStatus] WITH NOCHECK ADD
CONSTRAINT [PK_tblContractStatus] PRIMARY KEY CLUSTERED
(
[StatusID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblPhaseType] WITH NOCHECK ADD
CONSTRAINT [PK_tblPhaseType] PRIMARY KEY CLUSTERED
(
[PhaseTypeID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblDeals] WITH NOCHECK ADD
CONSTRAINT [PK_tblDeals] PRIMARY KEY CLUSTERED
(
[DealID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblPhase] WITH NOCHECK ADD
CONSTRAINT [PK_tblPhase] PRIMARY KEY CLUSTERED
(
[PhaseID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblProduction] WITH NOCHECK ADD
CONSTRAINT [PK_tblProduction] PRIMARY KEY CLUSTERED
(
[TransactionID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[tblDeals] ADD
CONSTRAINT [DF_tblDeals_StatusID] DEFAULT (5) FOR [StatusID]
GO

ALTER TABLE [dbo].[tblProduction] ADD
CONSTRAINT [DF_tblProduction_TransactionTimeStamp] DEFAULT (getdate()) FOR [TransactionTimeStamp]
GO

ALTER TABLE [dbo].[tblDeals] ADD
CONSTRAINT [FK_tblDeals_tblCompany] FOREIGN KEY
(
[CompanyID]
) REFERENCES [dbo].[tblCompany] (
[CompanyID]
),
CONSTRAINT [FK_tblDeals_tblContractStatus] FOREIGN KEY
(
[StatusID]
) REFERENCES [dbo].[tblContractStatus] (
[StatusID]
),
CONSTRAINT [FK_tblDeals_tblPhaseType] FOREIGN KEY
(
[PhaseTypeID]
) REFERENCES [dbo].[tblPhaseType] (
[PhaseTypeID]
)
GO

ALTER TABLE [dbo].[tblPhase] ADD
CONSTRAINT [FK_tblPhase_tblPhaseType] FOREIGN KEY
(
[PhaseTypeID]
) REFERENCES [dbo].[tblPhaseType] (
[PhaseTypeID]
)
GO

ALTER TABLE [dbo].[tblProduction] ADD
CONSTRAINT [FK_tblProduction_tblDeals] FOREIGN KEY
(
[DealID]
) REFERENCES [dbo].[tblDeals] (
[DealID]
),
CONSTRAINT [FK_tblProduction_tblPhase] FOREIGN KEY
(
[PhaseID]
) REFERENCES [dbo].[tblPhase] (
[PhaseID]
)
GO


exec sp_addextendedproperty N'MS_Description', N'Identifier', N'user', N'dbo', N'table', N'tblContractStatus', N'column', N'StatusID'
GO
exec sp_addextendedproperty N'MS_Description', N'Description', N'user', N'dbo', N'table', N'tblContractStatus', N'column', N'Status'


GO


exec sp_addextendedproperty N'MS_Description', N'Determines the type of phase structure this deal will go through', N'user', N'dbo', N'table', N'tblDeals', N'column', N'PhaseTypeID'
GO
exec sp_addextendedproperty N'MS_Description', N'Identifies the current status of deal', N'user', N'dbo', N'table', N'tblDeals', N'column', N'StatusID'


GO


exec sp_addextendedproperty N'MS_Description', N'Determines the percentage value of the phase', N'user', N'dbo', N'table', N'tblPhase', N'column', N'PhasePercentage'


GO


exec sp_addextendedproperty N'MS_Description', null, N'user', N'dbo', N'table', N'tblProduction', N'column', N'TransactionTimeStamp'


GO



---------------------------------------
And here's some data
---------------------------------------

INSERT INTO [tblPhaseType] ([Desription])VALUES('TV Commercial - 4 Phases')
INSERT INTO [tblPhaseType] ([Desription])VALUES('Full Campaign - 6 Phases')


INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(1,'Customer Info',1.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(1,'Write script',2.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(1,'Shoot',3.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(1,'Edit commercial',2.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Customer info',1.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Write script',1.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Design print ad',1.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Shoot',1.500000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Edit',2.000000000000000e-001)
INSERT INTO [tblPhase] ([PhaseTypeID],[PhaseDescription],[PhasePercentage])VALUES(2,'Publish',2.000000000000000e-001)


INSERT INTO [tblContractStatus] ([Status])VALUES('Completed')
INSERT INTO [tblContractStatus] ([Status])VALUES('Hold')
INSERT INTO [tblContractStatus] ([Status])VALUES('Collections')
INSERT INTO [tblContractStatus] ([Status])VALUES('Legal')
INSERT INTO [tblContractStatus] ([Status])VALUES('In Progress')


INSERT INTO [tblCompany] ([CompanyName])VALUES('Johnny''s Remodeling')
INSERT INTO [tblCompany] ([CompanyName])VALUES('Perfect Cut Lawncare')
INSERT INTO [tblCompany] ([CompanyName])VALUES('Useless Ideas Unlimited')
INSERT INTO [tblCompany] ([CompanyName])VALUES('Try-It-Again, Inc.')


INSERT INTO [tblDeals] ([CompanyID],[DealDate],[PhaseTypeID],[CashAmount],[StatusID])VALUES(1,'Aug 5 2003 12:00:00:000AM',1,120.0000,5)
INSERT INTO [tblDeals] ([CompanyID],[DealDate],[PhaseTypeID],[CashAmount],[StatusID])VALUES(2,'Sep 9 2003 12:00:00:000AM',2,150.0000,5)
INSERT INTO [tblDeals] ([CompanyID],[DealDate],[PhaseTypeID],[CashAmount],[StatusID])VALUES(3,'Sep 10 2003 12:00:00:000AM',2,130.0000,5)
INSERT INTO [tblDeals] ([CompanyID],[DealDate],[PhaseTypeID],[CashAmount],[StatusID])VALUES(4,'Nov 20 2003 12:00:00:000AM',1,190.0000,5)


INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(1,1,'Nov 10 2003 10:23:00:000AM','Received company logo')
INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(1,2,'Nov 10 2003 10:23:00:000AM','Finished writing script')
INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(2,5,'Nov 10 2003 10:23:00:000AM','Just received company info')
INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(2,7,'Nov 10 2003 10:24:00:000AM','Finished designing ad copy')
INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(1,3,'Nov 20 2003 11:29:00:000AM','Did more work')
INSERT INTO [tblProduction] ([DealID],[PhaseID],[TransactionTimeStamp],[Comments])VALUES(1,4,'Nov 20 2003 11:29:00:000AM','Finally finished the job')

View 3 Replies View Related

Writing Directly To A Csv From Asp.net Vb Behind

Jun 16, 2004

i have a query and i would like to write the contents of the dataset out directly to a file and not bother with creating another temp table and then exporting it with a command with a dts to a csv file.

it is a type of reporting that i am trying to do
but i just need to export the raw data i retreive from the query

View 3 Replies View Related

Writing Smart SQL

Oct 25, 1999

Is it possible to do the following without cursors or creating an identity column:

I have a table from legacy data with ~ 1 million records. I need to insert this into the new table which has a unique varchar(11) key. For the new system this key is generated by calling a SP that returns the next key in sequence. To put the legacy data records in the same table I want to first create a new column at end of legacy data table and populate this using SQL without going thru using cursor and calling the SP for each and every record to get a unique varchar(11) key.

In short here is what I want:

Field1 Field2 varchar(11)key

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

jsdhf dsf99 1LEG

878jh whjhj 2LEG

8728jh whjhj 3LEG

8578jh whjhj 4LEG

3878jh whjhj 5LEG

6878jh whjhj 6LEG

8508jh whjhj 7LEG

...

...

...

4878jh whjhj 1000000LEG

How do I generate this key using an SQL stmt?

Thanks in advance,

Nishi

View 4 Replies View Related

Help Writing A SQL Script

Oct 18, 1999

I have a table that has records that have multiple entries with only a slight varitation to accomodate client needs. I want to filter out the duplicates and call only one record row. How can I do this type of thing and make it work; example - SELECT * FROM clients WHERE client_id DISTINCT
I know that is not correct but that is what I need. I need to get all the columns but only one record for each client using the client_id field as the source of information.????

View 2 Replies View Related

Please Help Me In Writing A Query

Apr 5, 2006

I have table Products
I have coloumn like ProductName:
ProductName Having two values like Colgate and pepsi

I want to change these coloumn values in the result set
Please write a query

Hi here is clear question?

Table Name is Products
in that One coloumn name is
ProductsName:
and the values for productsName are
colgate
pepsi

the result set should be like following way

ProductsName:
Mike
Johnson

so here I am replacing value Mike instead of colgate
and Johnson instead of pepsi

View 1 Replies View Related

Help With Writing Query

Apr 14, 2006

Please help with writing query
I have 2 tables:
Table1:
IDDescription
1name1
2name2
3name3...

Table2:
SiDID
1231
4562
789myname
852yourname

if description exisits in table1 get description from table1 in
all other cases get ID from table2

View 5 Replies View Related

Help Writing Query

Apr 19, 2006

please help me write a query:
I have a user function dbo.udf_Valid which is return true or false
(@SID ,@PType,@Group,@Date)

Table 1 with this info:
SID PType Group
12 12 123
45 1 456

Table2 with this info:
PType PType2
12 13
12 45
12 8
1 8
1 9

when I pass the data from table1 to the function I am Okay.
The complexity starts when table2 is involved.
I need to pass PType2 to the function if Ptype is exists in table1.
If function returns true for one of the PType2 return true in all other cases false.

View 3 Replies View Related

Need Help Writing A Query

Aug 8, 2005

I need assistance on writing a particular query:

I need to be able to filter out duplicates that have different values in a particular field.

For example, I have a table that contains the following:


Code:


WBS1 WBS2 WBS3 Amount Section
123 13 00 475 F
123 13 00 0 L
123 21 01 125 C
123 24 03 50 L



I need to filter out the first two lines because they have the same values for the first three columns but the last column under 'Section' has different values.

Can someone help me?

Thanks

View 2 Replies View Related

Writing A Query

Apr 28, 2006

Hello I'm new on sql server and I wonder if there's an specific order for writing a query's clauses (joins, and other conditions in where clause or even the order of the tables in the from clause), I mean, I have a query that takes 1 minute executing, but if I execute the same query after moving the tables in the from clause (changing the order) It takes 5 seconds, could you please tell me Why ??? and what's the best order from writing a query ?


This is the query I was talking about:


SELECT TREP_VALOR_PRECIOS.CDPRECIO,
TREP_VALOR_PRECIOS.NMANO,
TREP_VALOR_PRECIOS.NMSEMANA,
ISNULL(DBO.FNCREP_VALORPRECIO(TREP_PRECIOS.CDPRECI O,0,TREP_VALOR_PRECIOS.NMSEMANA,TREP_VALOR_PRECIOS .NMANO),0) VRPAGO_COBRO,
UN_TASASCAMBI.TASTASACAMB VRTASA_CAMBIO,
TREP_PRECIOS.CDTIPO_PRECIO,
TREP_VALOR_PRECIOS.SNACTIVO,
'N' SNACTIVAR
FROM
UN_TASASCAMBI, -- I just moved this one to the end of the from clause
T2_CALENDARIO, -- I just moved this one to the end of the from clause
UN_MONEDEXTRA,
TREP_PRECIOS TREP_PRECIOS_BASE,
TREP_VALOR_PRECIOS,
TREP_PRECIOS
WHERE T2_CALENDARIO.CALFECHAINICIAL BETWEEN UN_TASASCAMBI.TASFECHDESD AND UN_TASASCAMBI.TASFECHHAST
AND UN_TASASCAMBI.TASCOMPANIA = UN_MONEDEXTRA.MEXCOMPANIA
AND UN_TASASCAMBI.TASMONECAMB = UN_MONEDEXTRA.MEXCODIGO
AND T2_CALENDARIO.CALSEMANA = TREP_VALOR_PRECIOS.NMSEMANA
AND T2_CALENDARIO.CALANO = TREP_VALOR_PRECIOS.NMANO
AND T2_CALENDARIO.CALTIPOFRUTA = '01'
AND UN_MONEDEXTRA.MEXCOMPANIA = TREP_PRECIOS_BASE.CDCOMPANIA
AND UN_MONEDEXTRA.MEXCODIGO = TREP_PRECIOS_BASE.CDMONEDA
AND TREP_PRECIOS_BASE.CDMONEDA <> 'PESOC'
AND TREP_PRECIOS_BASE.CDPRECIO = TREP_VALOR_PRECIOS.CDPRECIO
AND TREP_VALOR_PRECIOS.SNACTIVO = 'S'
AND TREP_VALOR_PRECIOS.CDPRECIO = DBO.FNCREP_OBTENER_PRECIO_BASE(TREP_PRECIOS.CDPREC IO)
AND TREP_PRECIOS.CDTIPO_PRECIO = 'F'

View 7 Replies View Related

Need Help Writing A Query...

Apr 15, 2008

Hi Friends,

I need help on writing an optimized query for the following problem..

Consider a table with columns "Date Emp1 Emp2"

Date Emp1 Emp2
1-feb 1 . . 2
2-feb 3 . . 4
3-feb 6 . . 1
4-feb 1 . . 2
5-feb 1 . . 5
6-Feb 5 . . 7


Now, I want search for records with employee id 1 in a way that if column emp1 contains 1 then I want the data in column emp2, and if column emp2 contains 1, then I want data in column emp1.

The output has to be a single column with no duplicate values. In the above example, for employee id 1, the output would be, 2,5 and 6 only.

This table has lakhs of records. I have to scan both columns for a given employee id. What will be the most optimized way to retrieve the data faster. Also, do I need to restructure this table for faster data retrieval?
I have indexes on emp1 and emp2 columns. Do we need union here and if yes, what is the best optimized query for the same?

View 9 Replies View Related

Help In Query Writing

May 29, 2008

Hi,

Mine Below Query is taking too much execution time. I am using this query in one of my sp.
Is there any other way to write this query?

Declare @p_Location_Code nvarchar(10)
Declare @p_ShowNearFarRate int
DECLARE @p_Data_Show_Flag int


Set @p_ShowNearFarRate = 1
Set @p_Data_Show_Flag = 1


select
X.Main_Party_Role ,
X.SET_ID,
X.TradeVisionId,
X.EntityId,
DBO.GET_ENTITY_TICKER (X.EntityId) Ticker,
X.Done,
X.MatchDate,
X.Main_Party_Id,
X.BUYER_MNEMONIC,
X.SELLER_MNEMONIC,
X.Other_Party_Id,
DBO.GET_DDMONYYYY_DATE_FORMAT(X.Main_Near_Dt) Main_Near_Dt,
DBO.GET_DDMONYYYY_DATE_FORMAT(X.Main_Far_Dt) Main_Far_Dt,
X.Amounts,
'Amount' = Case When ((ISNULL(X.Amount,0) >20) ) then Case When @p_Location_Code = 'NY44' then '20+' Else convert(nvarchar,x.Amount) End Else convert(nvarchar,x.Amount) End,
X.Price,
X.Duration,
X.Other_Party_Bro,
X.Main_Party_Bro,
X.Main_Party_State,
X.Other_Party_State,
'Main_Party_Near_Parse' = Case When (X.Main_Party_State=184 and X.Other_Party_State=184) THEN X.Main_Party_Near_Parse Else Case When @p_ShowNearFarRate = 1 then X.Main_Party_Near_Parse End End,
'Main_Party_Far_Parse' = Case When (X.Main_Party_State=184 and X.Other_Party_State=184) THEN X.Main_Party_Far_Parse Else Case When @p_ShowNearFarRate = 1 then X.Main_Party_Far_Parse End End,
X.Main_Party_Spread BPS,
'Main_Party_Amt' = Case When @p_Location_Code <> 'NY44' then X.Main_Party_Amt Else Case When (ISNULL(X.DONE,0) = 1 or X.Main_Party_State = 184 or X.Main_Party_State = 106) then X.Main_Party_Amt Else Case When ISNULL(X.Main_Party_Amt,0) <= 20 then X.Main_Party_Amt Else 20 End End End,
X.Other_Party_Near_Parse,
X.Other_Party_Far_Parse,
X.Other_Party_Spread,
X.Other_Party_Amt,
X.LOCATION_CODE,
X.Color_Value Org_Color_Value,
'Color_Value' = Case When @p_Location_Code = 'NY44' then
Case When X.Color_Value=500 then 500 + X.CallMe_Btn_Value
Else Case When X.Color_Value>= 284 and Isnull(x.done,0) <> 1 then 284 + X.CallMe_Btn_Value
Else Case When X.Color_Value=201 then 0 + X.CallMe_Btn_Value
Else Case When X.Color_Value=200 then 0 + X.CallMe_Btn_Value
Else Case When X.Color_Value=184 then 0 + X.CallMe_Btn_Value
Else Case When X.Color_Value=106 then 16 + X.CallMe_Btn_Value
Else Case When X.Color_Value=101 then 0 + X.CallMe_Btn_Value
Else Case When X.Color_Value=100 then 0 + X.CallMe_Btn_Value
Else Case When X.Color_Value=16 then 16 + X.CallMe_Btn_Value
Else 0 + X.CallMe_Btn_Value
End
End
End
End
End
End
End
End
End
Else
Case When X.Color_Value>=300 then 300 + X.CallMe_Btn_Value
Else Case When X.Color_Value=284 then 284 + X.CallMe_Btn_Value
Else Case When X.Color_Value=201 then 201 + X.CallMe_Btn_Value
Else Case When X.Color_Value=200 then 200 + X.CallMe_Btn_Value
Else Case When X.Color_Value=184 then 184 + X.CallMe_Btn_Value
Else Case When X.Color_Value=106 then 106 + X.CallMe_Btn_Value
Else Case When X.Color_Value=101 then 101 + X.CallMe_Btn_Value
Else Case When X.Color_Value=100 then 100 + X.CallMe_Btn_Value
Else Case When X.Color_Value=16 then 16 + X.CallMe_Btn_Value
Else 0 + X.CallMe_Btn_Value
End
End
End
End
End
End
End
End
End
End,
X.Main_Party_Strike_State,
X.Other_Party_Strike_State,
'BACK_COLOR' = (DBO.Fn_Get_TradeVisionRR_Back_Color_Value (@p_Location_Code, X.Color_Value)) ,
'FORE_COLOR' = (DBO.Fn_Get_TradeVisionRR_Fore_Color_Value (@p_Location_Code, X.Color_Value))
FROM
(
SELECT
Y.TradeVisionFileIdSET_ID,
'BUYER'Main_Party_Role,
Y.TradeVisionId,
Y.EntityId,
Y.Done,
Y.MatchDate,
Y.BuyerIdMain_Party_Id,
DBO.GET_CUSTOMER_MNEMONIC(Y.BUYERId) BUYER_MNEMONIC,
'SELLER_MNEMONIC' = Case When Y.Done = 1 THEN DBO.GET_CUSTOMER_MNEMONIC(Y.SELLERID)
Else Case When ( @p_Location_Code <> 'NY44' AND Y.BuyerState = 184AND Y.BuyerState = 184AND Y.IsBNearPraceTouched = 1 AND Y.IsSNearPraceTouched = 1 AND Y.IsBFarPraceTouched = 1AND Y.IsSFarPraceTouched = 1 AND Y.IsBSpreadTouched = 1 AND Y.IsSSpreadTouched = 1 AND Y.IsBAmtTouched = 1 AND Y.IsSAmtTouched= 1 AND Y.BuyerNearPrace = Y.SellerNearPrace AND Y.BuyerFarPrace = Y.SellerFarPrace AND Y.BuyerSpread = Y.SellerSpreadAND Y.BuyerAmt = Y.SellerAmT) THEN DBO.GET_CUSTOMER_MNEMONIC(Y.SELLERID)
Else Case When isnull(@p_Data_Show_Flag,1)=3 THEN DBO.GET_CUSTOMER_MNEMONIC(Y.SELLERId)
Else '*'
End
End
End,
Y.SellerIdOther_Party_Id,
Y.NearDateMain_Near_Dt,
Y.FarDateMain_Far_Dt,
Y.AmountsAmounts,
Y.AmountAmount,
Y.PricePrice,
Y.DurationDuration,
Y.SellerBroOther_Party_Bro,
Y.BuyerBroMain_Party_Bro,
Y.BuyerStateMain_Party_State,
Y.SellerStateOther_Party_State,
Y.BuyerNearPraceMain_Party_Near_Parse,
Y.BuyerFarPraceMain_Party_Far_Parse,
Y.BuyerSpreadMain_Party_Spread,
Y.BuyerAmtMain_Party_Amt,
Y.SellerNearPraceOther_Party_Near_Parse,
Y.SellerFarPraceOther_Party_Far_Parse,
Y.SellerSpreadOther_Party_Spread,
Y.SellerAmtOther_Party_Amt,
Y.LOCATION_CODE,
Y.Buyer_Strike_StateMain_Party_Strike_State,
Y.Seller_Strike_StateOther_Party_Strike_State,
(DBO.GET_TRADEVISIONRR_TRADEVISIONID_CUST_STATUS('NY44', 18, Y.TradeVisionId,Y.TRADEVISION_VERSION ,'BUYER' )) Color_Value ,
'CallMe_Btn_Value' = Case When Y.Buyer_Strike_State = 206 then 1000 Else 0 End
from DBO.TradeVisionRR Y
WHERE
Y.LOCATION_CODE = @p_Location_Code
AND Y.TRADEVISION_VERSION = (DBO.GET_TRADEVISIONRR_SET_MAX_VERSION('NY44', '02/05/2008', 169 ,Y.TradeVisionId ))
AND Y.TRADEVISIONFILEID = 169
------------------------------------------------------------
UNION ALL
------------------------------------------------------------
select
Y.TradeVisionFileIdSET_ID,
'SELLER'Main_Party_Role,
Y.TradeVisionId,
Y.EntityId,
Y.Done,
Y.MatchDate,
Y.SellerIdMain_Party_Id,
'BUYER_MNEMONIC' = Case When Y.Done = 1 THEN DBO.GET_CUSTOMER_MNEMONIC(Y.BUYERID)
Else Case When (@p_Location_Code <> 'NY44' AND Y.BuyerState = 184AND Y.BuyerState = 184AND Y.IsBNearPraceTouched = 1 AND Y.IsSNearPraceTouched = 1 AND Y.IsBFarPraceTouched = 1AND Y.IsSFarPraceTouched = 1 AND Y.IsBSpreadTouched = 1 AND Y.IsSSpreadTouched = 1 AND Y.IsBAmtTouched = 1 AND Y.IsSAmtTouched= 1 AND Y.BuyerNearPrace = Y.SellerNearPrace AND Y.BuyerFarPrace = Y.SellerFarPrace AND Y.BuyerSpread = Y.SellerSpreadAND Y.BuyerAmt = Y.SellerAmT) THEN DBO.GET_CUSTOMER_MNEMONIC(Y.BUYERID)
Else Case When isnull(@p_Data_Show_Flag,1)=3 THEN DBO.GET_CUSTOMER_MNEMONIC(Y.BUYERID)
Else '*'
End
End
End,
DBO.GET_CUSTOMER_MNEMONIC(Y.SELLERID) SELLER_MNEMONIC,
Y.BuyerIdOther_Party_Id,
Y.NearDateMain_Near_Dt,
Y.FarDateMain_Far_Dt,
Y.AmountsAmounts,
Y.AmountAmount,
Y.PricePrice,
Y.DurationDuration,
Y.BuyerBroOther_Party_Bro,
Y.SellerBroMain_Party_Bro,
Y.SellerStateMain_Party_State,
Y.BuyerStateOther_Party_State,
Y.SellerNearPraceMain_Party_Near_Parse,
Y.SellerFarPraceMain_Party_Far_Parse,
Y.SellerSpreadMain_Party_Spread,
Y.SellerAmtMain_Party_Amt,
Y.BuyerNearPraceOther_Party_Near_Parse,
Y.BuyerFarPraceOther_Party_Far_Parse,
Y.BuyerSpreadOther_Party_Spread,
Y.BuyerAmtOther_Party_Amt,
Y.LOCATION_CODE,
Y.Seller_Strike_StateMain_Party_Strike_State,
Y.Buyer_Strike_StateOther_Party_Strike_State,
(DBO.GET_TRADEVISIONRR_TRADEVISIONID_CUST_STATUS('NY44', 169, Y.TradeVisionId,Y.TRADEVISION_VERSION ,'SELLER' )) Color_Value ,
'CallMe_Btn_Value' = Case When Y.Seller_Strike_State = 206 then 1000 Else 0 End
from DBO.TradeVisionRR Y
WHERE
Y.LOCATION_CODE = @p_Location_Code
AND Y.TRADEVISION_VERSION = (DBO.GET_TRADEVISIONRR_SET_MAX_VERSION('NY44', '02/05/2008', 169 ,Y.TradeVisionId ))
AND Y.TRADEVISIONFILEID = 169
) X
where
X.EntityId IN ( Select Distinct Entity_Id from Fn_Get_Allowed_Entity_List('NY44' , 169 , '02/05/2008' ,200000 ))
and X.Main_Party_Id = 101901
Order By X.TradeVisionId

-- Regards
Prashant Hirani

View 7 Replies View Related







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