My company is working on a bond derivative portfolio analysis tool and
we're facing a problem that I did not see adequately addressed any
where in literature. I really did RTFM. I'm very experienced in
relational modelling (10+ years) so this is not a case of not
understanding the principles. Here is the problem stripped of
irrelevant context. The problem below is simplified for the sake of the
example so don't sweat the details.
THE PROBLEM
1. There are many types of bonds, each type has a different set of
attributes, different attribute names, different attribute datatypes.
For example, bond A has two variables: a yearly interest rate and
date of issue, B has five variables: an interest rate and 4 specific
dates on which various portions of principal need to be paid, bond C
has a set of 4 variables: interest rate in period 1, interest rate in
period 2, the date on which the bond can be put back to the issuer,
and two dates on which the bond can be called by the issue. And so on.
So, on the first attempt I could represent each bond type as its own
table. For example,
This is the nice relational approach but it does not work because:
2. There are many thousands of bond types thus we would have to have
many thousands of tables which is bad.
3. The client needs to be able construct the bond types on the fly
through the UI and add it to the system. Obviously, it would be bad if
each new type of bond created in the UI resulted in a new table.
4. When a user loads the bond portfolio it needs to be very fast. In
the table per type approach if a user has a 100 different types if bond
in the portfolio you would have to do 100 joins. This is a heavily
multi user environment so it's a non-starter. It's impossibly slow.
THE SOLUTIONS
So now that we ditched the table per bond type approach we can consider
the followiing solutions (unpleasant from the relational point of
view):
Comment: The client does not like this approach because they want to
run various kinds of reports and thus they doe not want the values to
be stored as VARCHAR. They want the DB to enforce the datatype.
Then you have to add some dynamic mapping in your code which will
provide bond specific mapping (say, stored in an XML file). For
example,
For bond_A: yearly_rate maps to int_val1, issue_date maps to date_val1
For bond_C: rate1 maps to int_val1, rate2 maps to int_val2, put_date
maps to date_val1, call_date maps to date_val2)
Comment: This is very good for performance because when I load a
portfolio of different bond types I can pull them all in in one SELECT
statement. However this approach has a problem that the table is
sparse. The number of fields of each type has to be as high as to
accmodate the most complex bond while simple bonds will only be using
two or three.
THE QUESTIONS:
Are the four approaches I described above exhaustive? Are there any
other that I overlooked?
I had to change the key columns of a dimension attribute to fix an error. I did this in BIDS. The change was from a single key column to a composite key column. Now I am getting these error when I process the cube:
Measure group attribute key column x does not match source attribute ..
I looked at the cube XMLA definition under mesaure groups and it still shows a single key column with inherited binding. However, the BIDS does not give me an option correct this in any way. I have had to do this once before and the only option seems to be removing the dimension from the cube and add it back in. But that is very error prone since I lose any specific settings at the cube dimension level not to mention aggregations no longer include the dimension, etc.
Not seeing an alternative, I went through each measure group (I have 7) and changed the key columns manually in the XMLA and saved the cube. This worked, but I don't understand why BIDS automatically doesn't do it.
Is this a flaw in the BIDS or I should be missing something.
i am trying to execute a query by joining two different tables.. one table is a local table and another one is a remote table..
The intresting thing is when i run the query from QUERY ANALYZER it works.. but if i execute the same from STORED PROCEDURE it gives me the following error.
Server: Msg 7405, Level 16, State 1, Line 1
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
Hi All, Can someone please tell me what does this means. and How to solw this problem. This is my procedure that I created.
CREATE PROCEDURE stp_Test @TableName varchar(50), @Id int out AS DECLARE @String varchar(500) SELECT @String = 'SELECT * INTO #TempTable FROM ServerName.Database.dbo.' + @TableName EXEC sp_sqlexec @String SELECT @id = max(ID) FROM #TempTable GO
WHEN I run this Procedure.
EXEC stp_Test 'TableName', @Id out
I get this out put.
------------------------------------------------------- SELECT * INTO #TempTable FROM ServerName.Database.dbo.TableName (1 rows affected)
Server: Msg 7405, Level 16, State 1, Procedure stp_MaxNoReturn, Line 2 Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
What is the solution to this problem. Thanks in advance Aziz
Hi Guys,I have one stored procedure on SQL 6.5 and retrieving data from SQL2000. I have defined a linked server on SQL 6.5. ButI am getting following error:-"Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS optionsto be set for the connection. This ensures consistent query semantics.Enable these options and then reissue your query."I dropped and re-create the stored procedure after adding the SETANSI_NULLS & SET ANSI_WARNINGS ON in stored procedure but still gettingthis error. I have created this sp on ISQL/W not in Enterprise Manager.Can anyone please let me know, how to fix this problem.ThanksAdnan
Hi,I want to get the string representation of a hex number from avarBinary column of a table.For example I want to get the output : 'The Hex value is 0xFF'butselect 'The Hex value is ' + convert(varchar(10), 0xFF)retruns the ascii charecter for 0xFFAny idea how do I get the hex form as it is?thanks.Supratim
In MS Access, for numeric fields, the decimal places shown can be defined as "Auto" meaning that the database will determine the number of decimal places to show based on the content of the field (i.e. 1.0, 0.75, 1.125).
In SQL Server for the same field, it appears that decimal precision is hard coded resulting in a fixed representation (i.e. 1.000, 0.750, 1.125)
Is there a way to make the decimal representation in SQL Server more like Access where trailing zeros are truncated?
I am using SQL server 7.0 and i have created oracle8i linked server(Using MSDAORA as provider) in it. When i run distributed queries between SQl server and Oracle server it works fine.But when i try to run distributed transaction between two servers ( BEGIN DISTRIBUTED TRANSACTION..)it reports an error saying Distributed transactions are not supported by MSDAORA.
My question is; is it possible to run distributed transaction between SQL server and oracle server (where oracle server is a linked server in my SQL server)?
Actually i want to run this transaction in DTS package which updates and transfers data amongst various servers.
I am trying to take a hexadecimal representation of a binary number and convert to the true binary representation so that I can compare it against a binary field in one of my tables.
After reading the documentation it seems I should be able to do this with the CAST or CONVERT function. However it does not appear to be working correctly.
Can you tell me why this T-SQL code produces the wrong binary value:
Here is my sample table creation and insertion script. I want represent as a summary-result using just one record. How can I ? Please note the below red color text.
create table policy ( id int not null, name nvarchar(50) not null, constraint pk_policy primary key(id) );
create table localhost ( policy_id int not null, id int not null, ip_begin binary(4) not null, ip_end binary(4) not null, prefix tinyint not null default 0, constraint pk_localhost primary key(policy_id,id) );
create table remotehost ( policy_id int not null, id int not null, ip_begin binary(4) not null, ip_end binary(4) not null, prefix tinyint not null default 0, constraint pk_remotehost primary key(policy_id,id) );
create table rate ( policy_id int not null, inbound int not null, outbound int not null, constraint pk_rate primary key(policy_id) );
------------- insert into policy values(0,N'policy0');
insert into localhost values(0,0,0xC0A80101,0xC0A80101,24); insert into localhost values(0,1,0xC0A80A01,0xC0A80B01,0);
insert into remotehost values(0,0,0xACA80101,0xACA80101,0); insert into remotehost values(0,1,0xACA80A01,0xACA80B01,0); insert into remotehost values(0,2,0xACA80C01,0xACA80C01,24);
insert into rate values(0,1000,2000);
------------- select * from policy; select * from localhost; select * from remotehost; select * from rate;
-- result of policy table 0 policy0
-- result of localhost table 0 0 0xC0A80101 0xC0A80101 24 0 1 0xC0A80A01 0xC0A80B01 0
-- result of remotehost table 0 0 0xACA80101 0xACA80101 0 0 2 0xACA80C01 0xACA80C01 24
-- result of rate table 0 1000 2000
------------------------------------------------------ desired result set id name localhost remotehost rate -- ---------- ---------------------------------------------------------------- ------------------------------------------- ----------------- 0 policy0 (192.168.1.1/24),(192.168.10.1~192.168.11.1) (172.168.1.1),(172.168.12.1/24) 0,1000,2000
descriptin of desired result set : 0. key value is id column and is referenced by each policy_id column. 1. id and name column is the same as policy table's. 2. localhost and remotehost columns are intigration of ip_begin,ip_end,prefix. 3. ip_begin and ip_end should be converted dotted presention from numeric format. 4. if prefix greater than 0, it should be displayed using '/'. 5. if ip_begin and ip_end are equal, show just one ip. 6. if the two ips are different from each other, they separated by '~'. 7. rate field is packed divided by ','.
DECLARE @a varchar(100) SET @a = @FailedRegionServerName + '.Ithalat.dbo.Product'
DECLARE @s varchar(100) SET @s = ' SELECT * FROM ' + @a EXEC ( @s )
When I execute it I get the error:
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
Then I put SET ANSI_WARNINGS ON SET ANSI_NULLS ON lines into the procedure. Also checked "Ansi Nulls" and "Ansi Warnings" in the properties of SQL Server. It didn't work
Then I tried:
DECLARE @s varchar(300) SET @s = 'SET ANSI_WARNINGS ON; SET ANSI_NULLS ON; SELECT * FROM ' + @a EXEC ( @s )
I still got the error.
WHAT SHOULD I DO? HOW CAN I GET A TABLE CONTENT FROM A LINKED SERVER? Any will be appreciated, thanks a lot...
Our customer (of our ecommerce system) wants to be able to preservedeleted entities in the database so that they can do reporting,auditing etc.The system is quite complex where each end user can belong to multipleinstitutional affiliations (which can purchase on behalf of the user).The end user also has a rich trail of past transactions affiliationsetc. Thus in the schema each user entity is related to many otherswhich in turn relate to yet others and so on.In the past when a user was deleted all of his complex relationshipswere also deleted in a cascading fashion. But now the customer wantsus to add a "deleted" flag to each user so that a user is never_really_ deleted but instead his "deleted" flag is set to true. Thesystem subsequently behaves as if the user did not exist but thecustomer can still do reports on deleted users.I pointed out that it is not as simple as that because the user entityis related to many, many others so we would have to add this "deleted"flag to every relationship and every other entity and thus have"deleted" past purchases, "deleted" affiliations - a whole shadowschema full of such ghost entities. This would overtime degradeperformance since now each query in the system has to add a clause:"where deleted = 0".I assume this is a standard problem since many organizations must havethis need of preserving deleted records (for legal or other reasons).I tried to talk them into creating a simple audit file where all thedeletions will be recorded in XML but they were not too happy withthat.Is there a more satisfying solution to this than have this "deleted"flag?Thanks for your help,- robert
I have a Stored Procedure I am trying to run that joins to a remote database. I am able to see everything in the QA just fine with this (courtesy of Anatha):
SELECT DISTINCT a.* FROM LOCATION a, LinkServer.MC_Card.webuser.LOCATION b WHERE a.location_number = b.location_number
But I am trying to run this query in Stored Procedure(notice the 4-part name callout to the LinkedServer tables) which returns the error message:
Error 7405: Heterogeneous queries require ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
Here is the Stored Procedure: /****** Object: Stored Procedure dbo.spELRMCcardXtionByDate Script Date: 4/24/2001 11:51:27 AM ******/
CREATE PROCEDURE dbo.spELRMCcardXtionByDate @dcid nvarchar(255), @startDate datetime, @endDate datetime AS -- declare @dcid nvarchar(255) -- set @dcid = '1032' SELECT STORE.[Str#], STORE.[Dcid#], E.card_number, E.program_number , E.start_date, E.end_date, E.card_number, E.event_number , E.status, E.budget, E.scheduled_date, P.tx_time, P.purchase_amount , L.merchant_name FROM (STORE INNER JOIN LinkServer.MC_Card.webuser.EVENT E ON STORE.[DemoID#] = E.event_number) LEFT JOIN (LinkServer.MC_Card.webuser.LOCATION L RIGHT JOIN LinkServer.MC_Card.webuser.POS_TX P ON L.location_number = P.location_number) ON E.event_number = P.event_number WHERE (((STORE.[Dcid#])= @dcid)) AND E.scheduled_date BETWEEN @startDate AND @endDate ORDER BY STORE.[Str#] -- and E.card_number IS NOT NULL GO
I am trying to create a stored procedure that updates a table on another server. It give the me the error about requiring ANSI_NULLS and WARNINGS being set. How can I set these if they are not already set? I tried setting them within the stored procedure, but does not appear to be working. Unless I am doing something wrong. I am trying to add SET ANSI_NULLS ON and doing the same thing for WARNINGS. Any thougts or suggestion on what to do? Thanks for the help
I have an application running against a SQLServer 2005 Express. For some limitations, I had to access from the same application to another database, but I cannot change to another server.
So I have 2 created a second instances, where the first one refers the second one and I created synonyms in the first one to access to all the objects in the second one, to emulate a database in the first instances, but running on the second one. The final idea is to move to another server, but for the testing I use another instance.
But when I try to access to the aplication database, I hav the following error: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
I searched solutions for this issue, but I only found to add SET ANSI_NULLS ON and SET ANSI_WARNINGS ON to my connection, before the queries, but I can't, because I cannot change the application.
I have a SQL200 stored proc that gives me the error "Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query." when I try to execute it through the query analyzer.
I was able to create the stored proc fine but when I try to execute it through the query analyzer it gives me the above error. I do have Link Server select inside the stored proc. I have to turn of warnings inside the stored proc in order for it to not crash my vb6 recordset by putting in the SET ANSI_WARNINGS OFF SET NOCOUNT OFF SET ANSI_NULLS OFF or else my vb6 recordset crashes.
When I created the sproc, I did what every one was telling me to do in the forums by putting in the
SET ANSI_WARNINGS ON Go SET NOCOUNT ON GO SET ANSI_NULLS ON GO
CREATE Procedure usp_SprocName
AS SET ANSI_WARNINGS OFF SET NOCOUNT OFF SET ANSI_NULLS OFF
Hi, I'm setting up a heterogeneous transactional push replication with Sybase ASE 12.5.3 as subscriber. With management studio I try to create an procedure article with following properties
Copy extended properties : false Destination object name : pGS_RefuseRequest Destination object ownere : dbo Action if name is in use : keep existing object unchanged Replicate : Execution of the stored procedure Create schemas at Subscriber : false
When I save the article and then the publication I got following error message:
Can not add artice 'pGS_RefuseRequest'. Object was not found on server. Check if this object exists on the server. (Microsoft.SqlServer.Rmo)
That's realy strange because the wizard offered the procedure pGS_RefuseRequest in the list of possible articles.
Fortunatly I can create the article with following TSQL statement :
Can somebody help me with the following error while deploying my cube:
The attribute key cannot be found : dbo_fact_table, Column: datetime Value 25/10/1901 4:18:00 pm...
The year 1901 is included in the time period of the time dimension. The calendar includes the following dates : 1/1/1753 - 31/12/2007 (Time binding) Why this referential integrity error occurs ??
Please help me because it is urgent and I cannot find a solution..
Hi:I need to store MAC Addresses. What is the standard way of storing thistype of attribute? Datatype? I can't find any discussions about thisanywhere.Thx for any pointers.
Hi!I have a following problem: I need to select some attributes fromtable, i.e.first, third, fifth...Can anyone give me the hint how to do it. Is there some method to saysomthing like this:SELECT $1, $3, $5 which will refer to the 1st, 3rd and 5th attribute?Thanks!Mario.
This generates a 2 column table that later in the stored procedure is sent out via sp_send_dbmail. The problem I'm having is that I want the right (2nd) column of the table to be right-aligned. For some reason, the line "
N'<col align="left"></col><col align="right"></col>' +" doesn't right-align the 2nd column when the report is sent through email (althought it does work if I take the generated string a use it to manually create an HTML file). So I want to add something like:
SET @html = REPLACE(@html, '<td', '<td align="right"')
but I still want the left column to be left-aligned, and this right-aligns everything. Is it possible for me to use REPLACE (or some other string function) to replace every other (alternating) "<td", or should I be looking at parsing this string using some 2005 XML features (unfortunately, using a CLR function to do this is not an option, since I am not allowed to turn that on on the server I'm using)? Thanks in advance.
I am trying to create a linear regression model. The model is skipping lot of columns for regression. But I want model to use all the columns even if they are not valid. I use Forced_Regressor attribute while creating the model.
add mining model Regressiontableinput2_Model (
[id] ,
[Reading] PREDICT_ONLY,
[Const] regressor,
[HCDD] regressor,
[HHDD] regressor,
[Hr1] regressor,
[Hr2] regressor,
[Hr3] regressor, ) USING MICROSOFT_LINEAR_REGRESSION (FORCED_REGRESSOR=1)
I get the error
Error (Data mining): The 'FORCED_REGRESSOR' data mining parameter is not valid for the 'Regressiontableinput2_Model' model.
Can somedbody tell me what is the syntax for using FORCED_REGRESSOR
I am trying to generate an output using Productname from below xml which will look like:
B/C/ B/D/E demo xml: DECLARE @myDoc xml DECLARE @ProdID nvarchar(10) SET @myDoc = '<Root> <ProductDescription Productname="A" Productd="Road Bike">
[code]...
I have a query which works perfect but with nodes. similar way I am looking for the value column. I want a similar result from the function on "Value" column(value column is defined inside the below query) : B/D/E ....
with CTE_xpath as ( select T.C.value('local-name(.)', 'nvarchar(max)') as Name, T.C.query('./*') as elements, T.C.value('text()[1]', 'nvarchar(max)') as Value
i have a column in my table that will store the sum of 3 other column, e.g the data in total_book column will be equal to the sum of the number in the romance, fiction and thriller column. how do i do this?