Procedura per utilizzare le trasformazioni XSLT senza dover ogni volta salvare il file ottenuto e quello in input per la trasformazione... Per fare ciò è possibile utilizzare le memory stream come descritto:
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim reader As New XmlTextReader(ds.GetXml(), XmlNodeType.Document, Nothing)
' Leggo il file XSLT
Dim xslfile As String = IO.Path.Combine(Request.PhysicalApplicationPath, "xslt\Trasformazione.xslt")
Dim x As New Xsl.XsltSettings
x.EnableScript = True
x.EnableDocumentFunction = True
Dim tra As New Xsl.XslCompiledTransform
tra.Load(xslfile, x, Nothing)
' Trasformo la DataTable XMLizzata in HTML
Dim ms As New MemoryStream
Dim myWriter As New XmlTextWriter(ms, Nothing)
Dim myXPathDoc As New XPath.XPathDocument(reader)
tra.Transform(myXPathDoc, Nothing, myWriter)
Utility.ConvertToString(ms)
alla fine è possibile utilizzare una funzione che converte la memorystream in una stringa.
lunedì 25 gennaio 2010
venerdì 22 gennaio 2010
Creare Server collegato con Sql Server 2008
Per collegare un server con Sql Server 2008 è sufficiente utilizzare la seguente procedura:
EXEC master.dbo.sp_addlinkedserver
@server = N'ServerName',
@srvproduct='',
@provider=N'SQLNCLI',
@datasrc=N'IndirizzoIp\Istanza', -- se Istanza definita, altrimenti basta l'IndirizzoIp
@catalog=N'DatabaseName'
Per modificare l'username di default per collegarsi a tale server la procedura da lanciare è questa:
EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname = N'ServerName',
@useself = 'FALSE',
@locallogin = NULL,
@rmtuser = 'Username',
@rmtpassword = 'Password'
EXEC master.dbo.sp_addlinkedserver
@server = N'ServerName',
@srvproduct='',
@provider=N'SQLNCLI',
@datasrc=N'IndirizzoIp\Istanza', -- se Istanza definita, altrimenti basta l'IndirizzoIp
@catalog=N'DatabaseName'
Per modificare l'username di default per collegarsi a tale server la procedura da lanciare è questa:
EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname = N'ServerName',
@useself = 'FALSE',
@locallogin = NULL,
@rmtuser = 'Username',
@rmtpassword = 'Password'
venerdì 8 gennaio 2010
Attività di pulitura di un DataBase
Ecco un comodo script per pulire un database:
USE [NomeDatabase]
--
-- Attività Controlla integrità database
--
DBCC CHECKDB WITH NO_INFOMSGS
GO
--
-- Attività Elimina contenuto cronologia
--
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
exec msdb.dbo.sp_delete_backuphistory @dt
GO
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date=@dt
GO
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
EXECUTE msdb..sp_maintplan_delete_log null,null,@dt
--
-- Attività Ricostruisci indice
--
USE NomeDatabase
DECLARE @tabella varchar(255)
DECLARE cursore_tabella CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'
OPEN cursore_tabella
FETCH NEXT FROM cursore_tabella INTO @tabella
WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@tabella,' ',90)
FETCH NEXT FROM cursore_tabella INTO @tabella
END
CLOSE cursore_tabella
DEALLOCATE cursore_tabella
--
-- Attività Compatta database
--
DBCC SHRINKDATABASE(N'NomeDatabase', 10, TRUNCATEONLY)
GO
USE [NomeDatabase]
--
-- Attività Controlla integrità database
--
DBCC CHECKDB WITH NO_INFOMSGS
GO
--
-- Attività Elimina contenuto cronologia
--
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
exec msdb.dbo.sp_delete_backuphistory @dt
GO
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date=@dt
GO
declare @dt datetime select @dt = CAST(FLOOR(CAST(getdate() AS FLOAT))AS DATETIME)
EXECUTE msdb..sp_maintplan_delete_log null,null,@dt
--
-- Attività Ricostruisci indice
--
USE NomeDatabase
DECLARE @tabella varchar(255)
DECLARE cursore_tabella CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'
OPEN cursore_tabella
FETCH NEXT FROM cursore_tabella INTO @tabella
WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@tabella,' ',90)
FETCH NEXT FROM cursore_tabella INTO @tabella
END
CLOSE cursore_tabella
DEALLOCATE cursore_tabella
--
-- Attività Compatta database
--
DBCC SHRINKDATABASE(N'NomeDatabase', 10, TRUNCATEONLY)
GO
Iscriviti a:
Post (Atom)