Using T-SQL REPLACE (or XML) To Add An Attribute To Every Other &&<td&&> Tag
Jan 10, 2008
I have the following as part of a stored procedure that generates an HTML report based on the data inserted into the table variable "@tblTemp":
SET @html =
N'<table border="1" width="0" style="font-family: Verdana, sans-serif;">' +
N'<tr><th>Name></th><th>ID</th></tr>' +
N'<col align="left"></col><col align="right"></col>' +
CAST ( ( SELECT td = [Name], '',
td = IDNumber
FROM @tblTemp
ORDER BY ID
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' ;
SET @html = @html + N'<br /><br /><img src="muuscreenshot.jpg" width="452" height="507" alt="sample.aspx" />'
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.
-Dave
View 7 Replies
ADVERTISEMENT
Aug 10, 2015
I want to insert attibute att1 in field F1 . Value for this attribute is content of another field in this table (F2).
My query :
update MyTable
set F1.modify
('insert attribute att1 {sql:column("F2")} into (/ROOT/Node1)[1]')
Where F1 Is not null
But I get this error :
XML well-formedness check: Duplicate attribute 'att1'. Rewrite your XQuery so it returns well-formed XML.
How do I check the douplicate attribute ?
View 0 Replies
View Related
May 16, 2008
HI,
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.
thanks
MJ
View 3 Replies
View Related
Jun 25, 2004
Does someone could explain me the NOCASE attribute in the order by line?
I cant find that anywhere.
Thanks a lot,
venusgirrl
View 4 Replies
View Related
Jun 3, 2007
Hello !
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..
Thanks
View 1 Replies
View Related
Sep 10, 2007
What happens if a column which has been defined so that it should not be Nullable is passed a value which is null?
i.e. IDNumber - Primary Key and Nullable = No.
Thanks
View 3 Replies
View Related
Dec 11, 2007
can someone please tell me if you can implement a drop down list within a table attribute.
If anyone could show me an example please do.
Kind Regards
Rob
View 11 Replies
View Related
Aug 10, 2005
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.
View 1 Replies
View Related
Jul 20, 2005
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.
View 5 Replies
View Related
Jan 9, 2008
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
Thanks,
DMNovice
View 4 Replies
View Related
Jun 30, 2015
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
[code]...
View 13 Replies
View Related
Oct 11, 2007
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?
View 1 Replies
View Related
Mar 10, 2008
I am trying to retrive some values from and XML data colum , along with that i need other normal column data also . how can i do that ?
here is my problem
I have a table with 2 colum .
Column Data Type
ID Int
Data XML
The XML data looks like following
<A>
<B a = 'sun' b = 'Red' >
</B>
<A>
I want to get each id and the 'b' attribute of the B node of the xml data for each row ?
Please help me if there is any simple way to do this .
View 5 Replies
View Related
Jan 21, 2008
Hi everyone,
I heard that it is possible to make more than one attribute(coloumn) primary key. Is this really possible, logical, productive and beneficial ?
Thanks
View 4 Replies
View Related
Aug 6, 2007
How can I set an attribute of unsigned zerofill in SQL? Like for example, there is an option in MySQL phpmyadmin to set the attribute of a specific column to unsigned zerofill, it will be based on the length of the integer. For example, the lenght of my int is 5, so if i'll set the attribute of the column to unsigned zerofill, the value that will be auto incremented will have zeroes before that actual value, for example000010000200003....00010and so on and so forth...But, how can i do this in SQL? I'm using MS SQL Server Management Studio Express, but I can't find the field attributes to set it to unsigned zerofill.. I hope somebody will reply in this post.. :(
View 5 Replies
View Related
Jan 6, 2008
Hi,I actualy have a problem with the connection to the databasefile that is stored within the websitetree by visual webdeveloper.I'm told that the attribute AttachDbFile is not understood. How have I to define which database (.mdf-file) should be taken that contains thetables that are needed in the later processing.Here the actual code:Imports Microsoft.VisualBasicImports SystemImports System.DataImports system.Data.SqlClientImports System.WebImports System.XmlPartial Class admin_news Inherits System.Web.UI.Page Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound If DetailsView1.CurrentMode = DetailsViewMode.Insert Then DirectCast(DetailsView1.FindControl("datumTextbox"), TextBox).Text = Now End If If DetailsView1.CurrentMode = DetailsViewMode.Edit Then DirectCast(DetailsView1.FindControl("datumTextbox"), TextBox).Text = Now End If End Sub 'Prozedur wird bei Update ausgeführt Public Sub DetailsView1_Update(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Dim conn As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFile=C:Pferdeservice KarleApp_dataPferde.mdf;Integrated Security=True Connection Timeout=30;User Instance=True") conn.Open() Dim cmd As New SqlCommand() Dim cmd1 As New SqlCommand() cmd.Connection = conn Dim sqlUpdate As String Dim sqlUpdate1 As String sqlUpdate = "UPDATE News_Kultur set Header = " sqlUpdate &= DirectCast(DetailsView1.FindControl("Headers"), TextBox).Text sqlUpdate &= "Ueberschrift_D =" sqlUpdate &= DirectCast(DetailsView1.FindControl("Ueberschrift_D"), TextBox).Text sqlUpdate &= "Ueberschrift_E =" sqlUpdate &= DirectCast(DetailsView1.FindControl("Ueberschrift_E"), TextBox).Text sqlUpdate &= "Text_D" sqlUpdate &= DirectCast(DetailsView1.FindControl("Text_D"), TextBox).Text sqlUpdate &= "Text_E" sqlUpdate &= DirectCast(DetailsView1.FindControl("Text_E"), TextBox).Text sqlUpdate &= "WHERE (((News_Kultur.ID)=" sqlUpdate &= DirectCast(DetailsView1.FindControl("ArtikelID"), TextBox).Text cmd.CommandText = sqlUpdate sqlUpdate1 = "UPDATE News set Datum=" sqlUpdate1 &= DirectCast(DetailsView1.FindControl("datumTextbox"), TextBox).Text sqlUpdate1 &= "WHERE ID=" sqlUpdate1 &= DirectCast(DetailsView1.FindControl("NewsID"), TextBox).Text cmd.CommandType = CommandType.Text cmd1.CommandType = CommandType.Text cmd.ExecuteNonQuery() cmd1.ExecuteNonQuery() conn.Close() End SubEnd Class
View 1 Replies
View Related
Jan 25, 2005
If I want to store day of the week (i.e. Mon), do I use datetime field or char? Also if I update #25/12/2004# to a datetime field. What is the value is the time port of the field? Thx.
View 10 Replies
View Related
May 2, 2008
Hey i have written a constraint trigger that will return an error message, but i want to include values from a count in the error msg. i know how it would be doing in oracle
RaisError('You cannot add more then' ||Bedroom_Count|| 'student tenants into this house', 10, 1)
how do i achieve the same result in MS SERVER
regards
QUISH
View 1 Replies
View Related
Apr 4, 2007
Hello, first time here, first time messing with SQL.
When creating a table in SQLServer2005 can you specify a column to be for a derived attribute. example a column monthlysalary and create a column that is a derived attribute - yearly salary. Is this done when creating the table and how is the syntax ?
View 7 Replies
View Related
Jul 23, 2005
My company is working on a bond derivative portfolio analysis tool andwe're facing a problem that I did not see adequately addressed anywhere in literature. I really did RTFM. I'm very experienced inrelational modelling (10+ years) so this is not a case of notunderstanding the principles. Here is the problem stripped ofirrelevant context. The problem below is simplified for the sake of theexample so don't sweat the details.THE PROBLEM1. There are many types of bonds, each type has a different set ofattributes, different attribute names, different attribute datatypes.For example, bond A has two variables: a yearly interest rate anddate of issue, B has five variables: an interest rate and 4 specificdates on which various portions of principal need to be paid, bond Chas a set of 4 variables: interest rate in period 1, interest rate inperiod 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 owntable. For example,create table bond_type_a (rate INTEGER, issue_date DATE)create table bond_type_b (rate INTEGER, principle_date1 DATE,principle_date2 DATE, principle_date3 DATE, principle_date4 DATE)create table bond_type_c (rate1 INTEGER, rate2 INTEGER, put_date DATE,call_date DATE)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 havemany thousands of tables which is bad.3. The client needs to be able construct the bond types on the flythrough the UI and add it to the system. Obviously, it would be bad ifeach 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. Inthe table per type approach if a user has a 100 different types if bondin the portfolio you would have to do 100 joins. This is a heavilymulti user environment so it's a non-starter. It's impossibly slow.THE SOLUTIONSSo now that we ditched the table per bond type approach we can considerthe followiing solutions (unpleasant from the relational point ofview):1. Name-Value pairs.create table bonds (bond_id INTEGER, bond_type INTEGER, attribute_idINTEGER, value VARCHAR(255))Comment: The client does not like this approach because they want torun various kinds of reports and thus they doe not want the values tobe stored as VARCHAR. They want the DB to enforce the datatype.2. Typed Name-Value pairs.create table bonds (bond_id INTEGER, bond_type INTEGER, attribute_idINTEGER, int_val INTEGER, string_val VARCHAR(255), date_val DATE_Comment: The client does not like this because the table is sparse.Every row has two empty fields.3. Link table with table per data type.create table bonds (bond_id INTEGER)create table bond_int_data (bond_id INTEGER REFERENCES bonds(bond_id),value INTEGER)create table bond_string_data (bond_id INTEGER REFERENCESbonds(bond_id), value VARCHAR(255))create table bond_date_data (bond_id INTEGER REFERENCES bonds(bond_id),value DATE)Comment: This meets most of the requirements but it just looks ugly.4. Dynamic Mappingcreate table (bond_id INTEGER, int_val1 INTEGER, int_val2 INTEGER,date_val1 DATE, date_val2 DATE, string_val1 VARCHAR(255), string_val2VARCHAR(255))Then you have to add some dynamic mapping in your code which willprovide bond specific mapping (say, stored in an XML file). Forexample,For bond_A: yearly_rate maps to int_val1, issue_date maps to date_val1For bond_C: rate1 maps to int_val1, rate2 maps to int_val2, put_datemaps to date_val1, call_date maps to date_val2)Comment: This is very good for performance because when I load aportfolio of different bond types I can pull them all in in one SELECTstatement. However this approach has a problem that the table issparse. The number of fields of each type has to be as high as toaccmodate the most complex bond while simple bonds will only be usingtwo or three.THE QUESTIONS:Are the four approaches I described above exhaustive? Are there anyother that I overlooked?
View 12 Replies
View Related
Jul 10, 2007
Hello All,
I am going through the Data Mining Web Control sample and have that working beautifully. I now want to add in some more functionality by allowing the end user to select the: database, model and tree to view in the web viewer (similar to the parameters in SSRS). I am trying to figure out a way to get all this data programatically. So far this is what I have:
Code Snippet
For Each newDB As Microsoft.AnalysisServices.Database In myserver.Databases
dbName = newDB.Name.ToString
myLog.AppendText("DATABASE NAME - " + dbName + vbCrLf)
For Each newStructure As Microsoft.AnalysisServices.MiningStructure In newDB.MiningStructures
structureName = newStructure.Name.ToString
myLog.AppendText(" STRUCTURE NAME [ " + structureName + " ]" + vbCrLf)
For Each newModel As Microsoft.AnalysisServices.MiningModel In newStructure.MiningModels
modelName = newModel.ToString
modelAlgorithm = newModel.Algorithm.ToString
myLog.AppendText(" MODEL NAME -" + modelName + " " + modelAlgorithm + vbCrLf)
This works beautifully but I am having a problem getting the tree name which i believe its called the "attribute_name".
I can run the following SQL against Analysis Services and get the attribute name but I would like to get all this programatically and insert into a table.
Code Snippet
SELECT attribute_name
FROM [model].content
WHERE node_type=2
I plan to run this daily and update a table. This will ultimately let me pull the structure into my data mining viewer page. This way, I will only have to have one viewer page for all models, instead of a new page for each.
Thanks,
Cam
View 3 Replies
View Related
Apr 2, 2008
Hello everyone,
I have an xml file that looks like this:
?xml version="1.0" encoding="UTF-8"?>
<WHOLE Date="*********">
<MAIN .......</MAIN>
</WHOLE>
What i need is to find a way to retrieve the value of the attribute belonging to the root element (value of @Date) in SSIS.
Tried it using Xpath but don't know how i should configure the xml task editor or if maybe there's any other way to perform such a task.
thank you
View 6 Replies
View Related
Nov 19, 2015
options for attribute generation. The query:
select 'Delivery' as "@DeliverableName"
,'Path' as "@TargetDirectoryPath"
for xml path('Deliverable'), type
generates the following:
<Deliverable DeliverableName="Delivery" TargetDirectoryPath="Path" />
We are interfacing to a third party package that only accepts single quoted attributes:
<Deliverable DeliverableName='Delivery' TargetDirectoryPath='Path' />
Is there an option which will control the enclosing quotes?
View 3 Replies
View Related
Aug 17, 2007
Hi guys,
I'm trying to find some attributes within a database I'm working with. I'm working with SQL Server 2000, and I'm trying to find table which have a certain attribute in them. for example, If I want to see tables from my database which have an attribute called 'home_address', what would the query be? Or is there an inbuilt function in SQL Server 2000 which allows me to search this?
Thank you!
View 4 Replies
View Related
Apr 30, 2015
Many dimensions don't have unique members. Instead, the dimension source data has duplicates at the leaf level: it's left up to SSAS to aggregate up to the actual leaf level used in hierarchies.
Every cube I've worked on in the past, a dimension is clearly defined in the source data, with uniqueness already present there: we don't make a dimension out of duplicated, sort of facty data. This kind of design seems as weird to me as an unnormalised SQL database.
Here's an example to illustrate what I mean; I'll use that Adventureworks database.
We have a Geography dimension with a Geography hierarchy. Levels go like this from top to bottom:
Country
State-Province
City
Postcode
The Geography dimension has a key attribute called Geography Key. It's there in the cube design as a dimension attribute, but it's not in any of the hierarchies, so I can't query it in MDX. But that's fine: it has the same cardinality as the lowest level (Postal Code), because the dimension has some kind of normal design.
In the cube I'm dealing with, it's all messed up. Using the AdventureWorks example above as a parallel, someone made a Geography dimension with source data keyed on [PostalCode, ExactAddress], but only wanted the dimension granularity to be PostalCode.
This makes it very hard to debug why the data in this dimension is incorrect. I can't match up the dimension members in the cube to the source data, because the dimension doesn't actually go down to the real leaf level!
So I have a dimension attribute called ExactAddressKey, but I can't query on it in MDX, because it's not part of any dimension hierarchy. Unfortunately changing any part of this cube design is not possible, so I can't even experiment with settings and see what happens.
How I could get to the leaf level of the data imported? Something like
Geography.Geography.TheInvisibleLeafLevel.Members.Properties('Key')
Or does this kind of dimension design result in SSAS discarding all the data that's more granular than the most granular attribute defined in any hierarchy - so that the data actually isn't there to be queried?
View 2 Replies
View Related
Apr 27, 2007
I am having one question about discretization of continous attributes
values. How does it work? I need this information for my thesis. I have a
continous attribut, namely SKS, with range 0-20. When I use Microsoft
Decision Tree algorithm, this attribut split in SKS <= 18 and SKS > 18. I
want to know how does it find 18 as a number to split not the other.
One question again about Microsoft Decision Tree algorithm, about
Complexity_Penalty parameter. How does it affect the algorithm? For example,
if I set this value=0.1 what does it mean and how does it correspond with
growth tree?
Thanks a lot before for your kindness to answer my questions.. :-)
View 1 Replies
View Related
Aug 28, 2015
How to move attribute from one dimension to another in a cube?
View 2 Replies
View Related
Jan 31, 2008
Is there a way to explicitly assign 'weights' or 'importance' factors to attributes and have that to be considered by the association rules and decision trees algorithms during training? I would like to do so without preprocessing the data (In any case, I can't think on a way to assign weight with preprocessing to boolean attributes like 'smoker')
thanks
View 3 Replies
View Related
Jun 12, 2006
Does anyone have an example of using the SqlTrigger attribute for a DDL trigger? Cannot seem to locate one?
View 9 Replies
View Related
Mar 16, 2006
I have managed to capture the file path through some SSIS tasks. Now I am looking to read get the File Name present for a file in this path. How can I possibly do this? Do I have to use the script task and write something up in VB.NET? Hope there is an easier way out. I have been trying to figure out the File SYstem task. But that seems really complicated as well. Please let me know. This is an emergency for a special DEMO. Thank you!!!
View 5 Replies
View Related
May 21, 2008
Hello SSAS gurus,
Recently i started learning working on Analysis services and writing MDX expressions, so please forgive my ignorance if this is a trivial question.
I ran out of s. Don't know what I should do to fix this. Please point me in the right direction.
We have a cube with one fact table(Imperative Fact) and two dimensions (Client, Client Imperative). A Client has several Imperatives. One of the attributes of Client Imperative dimension is Target Outcome. This is a text field.
We created a measure Client Imperative Count that gives the number of imperatives a client has.
The business defined 'Client Imperative' KPI as following :
If client has 1 or more imperatives and has Target outcome then show green. If client has 1 or more imperatives and does not haveTarget outcome then show yellow. if the client does not have imperative then show red.
Wrote the following KPI Status expression but it doesn't seem to work. Hitting a dead end. couldn't figure this out.
Code Snippet
Case
When
[Measures].[Client Imperatives Count] > 0
And
([Client Imperatives].[TRGT OTCM].currentmember <> null)
or
(Not IsEmpty([Client Imperatives].[TRGT OTCM].currentmember))
Then 1
When
[Measures].[Client Imperatives Count] > 0
And
([Client Imperatives].[TRGT OTCM].currentmember = null)
or
(IsEmpty([Client Imperatives].[TRGT OTCM].currentmember))
Then 0
Else
-1
End
Tried [Client Imperatives].[TRGT OTCM].value but didn't work.
Also, tried to create a calculated member for Target Outcome using following code. It is not working either.
Code Snippet
CALCULATE;
CREATE MEMBER CURRENTCUBE.[MEASURES].[Target Outcome]
AS case
when
[Client Imperatives].[TRGT OTCM].currentmember = [Client Imperatives].[TRGT OTCM].&[]
then 0
else 1
end,
VISIBLE = 1 ;
Trying to figure this out since two days. Somebody please help me.
I appreciate your help.
View 3 Replies
View Related
Jan 11, 2006
Greetings everyone. I'm trying to set up a GridView that makes use of an SQL Datasource. All commands (update,select,delete) are set within the tag's attributes but when i hit the Delete Trigger it returns that the id variable is undeclared. <asp:SqlDataSource ID="KevinDataSource" ConnectionString="Server=overmind;Database=kevin_bonis;User=sa;Password=" SelectCommand="SELECT * FROM Accesorii" UpdateCommand="Update Accesorii SET nume_accesoriu=@nume_accesoriu, articol=@articol, cantitate=@cantitate, trimis_bolla=@trimis_bolla, bolla=@bolla, data_trimitere=@data_trimitere, intors=@intors, data_intoarcere=@data_intoarcere WHERE id=@id" DeleteCommand="DELETE FROM Accesorii WHERE id = @id" runat="server" />What could be the problem with this? I'll appreciate any help i can get.Thanks alot, Allyrion
View 1 Replies
View Related
Dec 19, 2005
Hello
I am a newbye with Analysis Services and am desperately trying to find a way to include a calculation between one of my measures (Teus), divided by the vessel capacity, where vessel is one of my dimensions (and is therefore not depended on other dimensions...)
Any ideas how I could implement that ?? This would help a lot, thanks for your help,
Aurore Bui.
View 2 Replies
View Related