Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Friday, December 19, 2008

How to rename a Dynamicweb Stylesheet

In Dynamicweb CMS you have so-called "Stylesheets" which are used as containers for various page/site related settings: Layout, navigation etc. You cannot by default rename them - but if you are lucky to have access to the SQL database in which your soloution is store you can use these sql queries below to rename your stylesheets:

  1. Find the information about the excisting stylesheets:
    select * from StylesheetStylesheet where StylesheetStylesheetParentID = 0

    You will get information like this:
    StylesheetStylesheetID [Integer]
    StylesheetStylesheetParentID [Integer]
    StylesheetStylesheetNodename [String]
  2. To rename a given Stylesheet, use the above information to generate your sql query, for instance:
    UPDATE StylesheetStylesheet SET StylesheetStylesheetNodename = 'My new name'WHERE (StylesheetStylesheetID = '4')

Monday, July 7, 2008

Simulating SQL "DISTINCT" in XSLT

If you have a list of elements from which you only want one occurance of each unique value, in SQL you would just add "DISTINCT" infront of the column. You can do something in XSLT which gives you the same functionality. Take a look at this example:
//Product[Hight][not(Hight=preceding-sibling::Product/Hight)]
This example will do just that with Product elements with a subnode called Hight. So only one occurance of each Hight!

Thursday, March 13, 2008

Show tables in a database

If you want to know which tables are defined in a (MS) database you can enter this SQL query:

select name from sysobjects where xtype = 'U'
order by name

Monday, July 9, 2007

SQL: Returning XML in a query

Sometimes you want your query result to return as XML. MS SQL server 2005 offers this feature, and it's quite simple:


Normal result

Select a, b from myTable



XML result but returning coloumn values as XML-attributes

Select a, b from myTable for XML AUTO



XML result column as individual elements

Select a, b from myTable for XML AUTO, ELEMENTS

Thursday, July 5, 2007

Copy rows from one table to another

Sometimes you wish to copy contents from one table - for instance a backup table - to another table. That can be done using "insert into ... select", here is a simple example:


INSERT INTO table_target (col1, col2)
select col1, col2 from table_source
where new = 1
It will copy the rows from table_source where the col "new" contains 1 as news rows into table_target! Simple backup procedure :-)