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

Translations in XMLA  

Posted in ,

MSAS 2003/2005 supports translations for dimensions and measures.
In my task i must set translations for XMLA (OLAP) for PHP client.
(accessing by PHP SOAP through IIS)

If you want to use translations in MDX query you may use properites
like Properties("LCID1036"), where "LCID1036" is Locale ID.
Full article about it at sqlblog.com.

Other way is using custom caption in MDX query like this.


WITH member [Measures].[ruClients] as [Measures].[Clients],
caption = 'caption'
SELECT
{[Measures].[ruClients] } ON 0,
NON EMPTY [time].[week].children ON 1
FROM [payments]


Next you can set location in SOAP request. By using SQL Server Profiler Excel's XMLA
command can be found. Here exists field 1049.


< PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
< Catalog>SomeMSASDatabase
< LocaleIdentifier>1049
< DataSourceInfo/>
< Content>SchemaData
< Format>Tabular
< /PropertyList>


P.S. Sorry for my English :(

deleting duplicates  

Posted in ,

Deleting dublicate values from any table in SQL Server.
Key value (ID) may be changed.



SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[delete_dublicates_from_table]
@table nvarchar(255)
as begin
DECLARE @ID bigint
DECLARE @COUNT int
declare @query nvarchar(max)
declare @condamne table (
ids bigint,
counts int
)
set @query = 'SELECT [ID], COUNT([ID]) FROM '+@table+' GROUP BY [ID] HAVING COUNT([ID]) > 1 '
insert into @condamne exec sp_executesql @query
DECLARE CUR_DELETE CURSOR FOR
select * from @condamne
OPEN CUR_DELETE
declare @temp_query nvarchar(max)
FETCH NEXT FROM CUR_DELETE INTO @ID,@COUNT
WHILE @@FETCH_STATUS = 0
BEGIN
set @temp_query = (select 'DELETE TOP('+convert(nvarchar(3),@COUNT,120)+'-1) FROM '+@table+' WHERE ID = '+convert(nvarchar(32), @ID)+' ')
exec sp_executesql @temp_query
FETCH NEXT FROM CUR_DELETE INTO @ID,@COUNT
END
CLOSE CUR_DELETE
DEALLOCATE CUR_DELETE
end

SQL prompt  

Posted in



How i work without it..
Kilobytes of SQL broking my fingers in SQL Managment studio 2005.
SQL Prompt very powerful app to code SQL.
One man said, that all this functionality already exists in Oracle environment.
I don't know - never use Oracle.
Maybe in SQL Server 2008 i can find all this prompting stuff..

Don't start holy war - SQL server just my work.
It's much more powerful than MySQL.

Oh!. link - http://www.red-gate.com/products/SQL_Prompt/index.htm

SQL Server RegExp  

Posted in ,


sp_dbcmptlevel db_name, 90
EXEC sp_configure 'show advanced options' , '1';
go
reconfigure;
go
EXEC sp_configure 'clr enabled' , '1'
go
reconfigure;
EXEC sp_configure 'show advanced options' , '1';
go



public static partial class UserDefinedFunctions
{
public static readonly RegexOptions Options =
RegexOptions.IgnorePatternWhitespace |
RegexOptions.Singleline;

[SqlFunction]
public static SqlString RegexMatch(SqlChars input, SqlString pattern)
{
Regex regex = new Regex(pattern.Value, Options);
string data = new string(input.Value);
data.ToLower();
Match aMatch = regex.Match(data);
return aMatch.ToString();
}
};



select dbo.RegexMatch( N'123-45-6789', N'\d{2}' )

http://msdn.microsoft.com/en-us/magazine/cc163473.aspx

metanews


Add to Google