Implementation of a validity test with SQL Server Integration Services
Hi everyone! If
SSIS has great advantages in terms of debugging by design, it nevertheless remains largely a tool for improvement on a number of points.
The first of these is probably the weakness of function libraries accessible in the data conversion tasks. Indeed, the conventional tests to identify the correct classification of the imported data in a Data Flow (ISDATE, ISNUMERIC, ...) can not be made otherwise than by Script Component task ... A long and often tedious task to develop, particularly if the number of fields to be tested is especially important. If
to this important gap solution to redevelop a specific component for SSIS comes immediately to mind, the reality of deployment on the client catches up to us inexorably. Indeed, it is necessary to deploy the said component impacted on all servers that can quickly be tricky ...
So I come here to propose an alternative solution, although not very satisfactory for which I am a perfectionist: the use of temporary tables !
While SSIS does not have adequate functions, the Transact-SQL can come to our rescue!
should therefore integrate the data source into a temporary table independent of data format - eg VARCHAR fields - then make the changes and integrity checks as part of a stored procedure ...
If this remains lackluster, it is really the only viable solution as SQL Server Integration Services will not offer a library of components and functions satifaisante ...
continued ...
Monday, July 30, 2007
Women Over 60 In Girdles
Moving System databases SQL Server 2005 ...
Hello everyone!
Here is a post that should not leave indifferent those who carried out the laborious movement of all databases of a SQL instance, in particular the bases system!
While the movement of these bases is well documented in MSDN, it is nevertheless extremely tedious to undertake such an operation ... However, there
the significant effort that Microsoft has agreed to streamline the movement between the SQL Server 2000 and SQL Server 2005.
For the record, you will find here documentation for moving files from system databases in SQL Server 2000 and SQL Server 7.
Under SQL Server 2005, only moving databases and Master mssqlsystemresource, new database that did not exist in SQL Server 2000, requires special treatment.
I therefore propose here a customizable script that should delight young and old who want to move their databases SQL Server 2005 system with one click!
To exploit this code, save the file in a Visual Basic Script (eg c: \\ movedb.vbs) and run it!
Function newline (s)
newline = Replace (s, "\\ n", vbCrLf) End Function
Sub order (s)
shcmd.Run "cmd /C " & s,1,true
End Sub
Dim base(4)
base(0) = array("ma","","","","master.mdf","mastlog.ldf")
base(1) = array("rs","mssqlsystemresource","data","log","mssqlsystemresource.mdf","mssqlsystemresource.ldf")
base(2) = array("mo","model","modeldev","modellog","model.mdf","modellog.ldf")
base(3) = array("db","msdb","MSDBData","MSDBLog","MSDBData.mdf","MSDBLog.ldf")
base(4) = array("tp","tempdb","tempdev","templog","tempdb.mdf","templog.ldf")
Function baseray(s)
baseray = array () For Each row in
basis
If row (0) = s Then
baseray
= row End If End Function
Next
'Moves a database other than "master" and "resource"
Sub movenormal (row, s) =
database row (1)
If s = "d" Then
name = row (2) = File
row (4)
ElseIf s = "j" Then
name = row (3 )
file = row (5) End If
order ("sqlcmd-S" & instance & "-Q" ALTER DATABASE "& database &" MODIFY FILE (name = "& name &", FILENAME = '"& dest & "\\" & file & "')""")
command ("net stop" & & serviceinstance "/ yes)
command (" move "& src &" \\ "& file &" "" "" "& Dest &" "" ")
order (" net start "& serviceinstance)
End Sub 'Moves" master "and" resource "
Sub movemaster ()
row = base (0) =
fichierd row (4)
fichierj = row (5)
order (" net stop "& & serviceinstance" / yes)
'search and replace parameters
key = "HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Microsoft SQL Server \\ Instance Names \\ SQL \\" & keyinstance
cleinstance = shcmd.RegRead(cle)
cle = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\" & cleinstance & "\MSSQLServer\Parameters"
If s = "d" Then
shcmd.RegWrite cle & "\SQLArg0", "-d" & dest & "\" + fichierd, "REG_SZ"
commande("move """ & src & "\" & fichierd & """ """ & dest & """ ")
Elseif s = "j" Then
shcmd.RegWrite cle & "\SQLArg2", "-l" & dest & "\" + fichierj, "REG_SZ"
commande("move """ & src & "\" + fichierj & """ """ & dest & """ ")
End If
commande("net start " + serviceinstance + " /f /T3608")
row = base(1)
database = row(1)
nomd = row(2)
nomj = row(3)
fichierd = row(4)
fichierj = row(5)
If s = "d" Then
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " MODIFY FILE (name=" & nomd & ", FILENAME='" & dest & "\" & fichierd & "')""")
commande("move """ & src & "\" & fichierd & """ """ & dest & """ ")
Elseif s = "j" Then
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " MODIFY FILE (name=" & nomj & ", FILENAME='" & dest & "\" & fichierj & "')""")
commande("move """ & src & "\" & fichierj & """ """ & dest & """ ")
End If
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " SET READ_ONLY""")
commande("net stop " & serviceinstance & " /yes")
commande("net start " & serviceinstance)
End Sub
set shcmd = WScript.CreateObject ("WScript.Shell")
'Variables to redefine or manually by InputBox:
' SQL Server name and instance bases which are moved
server = InputBox ("Name Server ") If
server =" "Then WScript.Quit
instance = InputBox (" Instance Name (For the default instance, leave it blank) ")
If Replace (body," "," ") =" "Then
instance = server
serviceinstance =" MSSQLSERVER "
keyinstance =" MSSQLSERVER "
Else
instance = server &" \\ "& instance
serviceinstance =" MSSQL $ "& body
keyinstance = body End If
src = InputBox ("Source Path")
dest = InputBox ("Destination Path")
line = "Base (s) to move: \\ nmr: master + resource \\ ndb: MSDBData \\ NMO: model \\ ntp: tempdb \\ n (eg 'mr, tp') "
db = InputBox (newline (line)) line =
" Move (d) ata, (j) ewspapers \\ n or both (d, j) "
dj = InputBox (newline (line))
'line =" Parameters: \\ n source: "+ src +" \\ n-destination: "+ dest +" \\ n-base " db + + "\\ n-objects:" + dj
'msgbox (newline (line)) =
dbpar Split (Replace (db, "",""),",")
djpar = Split (Replace (dj," ",""),",")
For Each db In dbpar
If db <> "mr "Then r =
baseray (db)
If ubound (r)> -1 Then For Each
in djpar
movenormal dj r dj
Next End If Else
movemaster
End If Next
Good day!
Hello everyone!
Here is a post that should not leave indifferent those who carried out the laborious movement of all databases of a SQL instance, in particular the bases system!
While the movement of these bases is well documented in MSDN, it is nevertheless extremely tedious to undertake such an operation ... However, there
the significant effort that Microsoft has agreed to streamline the movement between the SQL Server 2000 and SQL Server 2005.
For the record, you will find here documentation for moving files from system databases in SQL Server 2000 and SQL Server 7.
Under SQL Server 2005, only moving databases and Master mssqlsystemresource, new database that did not exist in SQL Server 2000, requires special treatment.
I therefore propose here a customizable script that should delight young and old who want to move their databases SQL Server 2005 system with one click!
To exploit this code, save the file in a Visual Basic Script (eg c: \\ movedb.vbs) and run it!
Function newline (s)
newline = Replace (s, "\\ n", vbCrLf) End Function
Sub order (s)
shcmd.Run "cmd /C " & s,1,true
End Sub
Dim base(4)
base(0) = array("ma","","","","master.mdf","mastlog.ldf")
base(1) = array("rs","mssqlsystemresource","data","log","mssqlsystemresource.mdf","mssqlsystemresource.ldf")
base(2) = array("mo","model","modeldev","modellog","model.mdf","modellog.ldf")
base(3) = array("db","msdb","MSDBData","MSDBLog","MSDBData.mdf","MSDBLog.ldf")
base(4) = array("tp","tempdb","tempdev","templog","tempdb.mdf","templog.ldf")
Function baseray(s)
baseray = array () For Each row in
basis
If row (0) = s Then
baseray
= row End If End Function
Next
'Moves a database other than "master" and "resource"
Sub movenormal (row, s) =
database row (1)
If s = "d" Then
name = row (2) = File
row (4)
ElseIf s = "j" Then
name = row (3 )
file = row (5) End If
order ("sqlcmd-S" & instance & "-Q" ALTER DATABASE "& database &" MODIFY FILE (name = "& name &", FILENAME = '"& dest & "\\" & file & "')""")
command ("net stop" & & serviceinstance "/ yes)
command (" move "& src &" \\ "& file &" "" "" "& Dest &" "" ")
order (" net start "& serviceinstance)
End Sub 'Moves" master "and" resource "
Sub movemaster ()
row = base (0) =
fichierd row (4)
fichierj = row (5)
order (" net stop "& & serviceinstance" / yes)
'search and replace parameters
key = "HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Microsoft SQL Server \\ Instance Names \\ SQL \\" & keyinstance
cleinstance = shcmd.RegRead(cle)
cle = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\" & cleinstance & "\MSSQLServer\Parameters"
If s = "d" Then
shcmd.RegWrite cle & "\SQLArg0", "-d" & dest & "\" + fichierd, "REG_SZ"
commande("move """ & src & "\" & fichierd & """ """ & dest & """ ")
Elseif s = "j" Then
shcmd.RegWrite cle & "\SQLArg2", "-l" & dest & "\" + fichierj, "REG_SZ"
commande("move """ & src & "\" + fichierj & """ """ & dest & """ ")
End If
commande("net start " + serviceinstance + " /f /T3608")
row = base(1)
database = row(1)
nomd = row(2)
nomj = row(3)
fichierd = row(4)
fichierj = row(5)
If s = "d" Then
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " MODIFY FILE (name=" & nomd & ", FILENAME='" & dest & "\" & fichierd & "')""")
commande("move """ & src & "\" & fichierd & """ """ & dest & """ ")
Elseif s = "j" Then
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " MODIFY FILE (name=" & nomj & ", FILENAME='" & dest & "\" & fichierj & "')""")
commande("move """ & src & "\" & fichierj & """ """ & dest & """ ")
End If
commande("sqlcmd -S " & instance & " -Q ""ALTER DATABASE " & database & " SET READ_ONLY""")
commande("net stop " & serviceinstance & " /yes")
commande("net start " & serviceinstance)
End Sub
set shcmd = WScript.CreateObject ("WScript.Shell")
'Variables to redefine or manually by InputBox:
' SQL Server name and instance bases which are moved
server = InputBox ("Name Server ") If
server =" "Then WScript.Quit
instance = InputBox (" Instance Name (For the default instance, leave it blank) ")
If Replace (body," "," ") =" "Then
instance = server
serviceinstance =" MSSQLSERVER "
keyinstance =" MSSQLSERVER "
Else
instance = server &" \\ "& instance
serviceinstance =" MSSQL $ "& body
keyinstance = body End If
src = InputBox ("Source Path")
dest = InputBox ("Destination Path")
line = "Base (s) to move: \\ nmr: master + resource \\ ndb: MSDBData \\ NMO: model \\ ntp: tempdb \\ n (eg 'mr, tp') "
db = InputBox (newline (line)) line =
" Move (d) ata, (j) ewspapers \\ n or both (d, j) "
dj = InputBox (newline (line))
'line =" Parameters: \\ n source: "+ src +" \\ n-destination: "+ dest +" \\ n-base " db + + "\\ n-objects:" + dj
'msgbox (newline (line)) =
dbpar Split (Replace (db, "",""),",")
djpar = Split (Replace (dj," ",""),",")
For Each db In dbpar
If db <> "mr "Then r =
baseray (db)
If ubound (r)> -1 Then For Each
in djpar
movenormal dj r dj
Next End If Else
movemaster
End If Next
Good day!
Monday, June 18, 2007
Can I Get Herpes From A Tanning Bed?
Management queries on partitioned views ...
Hi everyone!
After numerous problems with partitioned views, I wish to clarify certain rules to use to avoid problems with these whimsical.
First, I want to talk about the case of date fields used as a partition key. The optimizer of SQL Server is not able to correctly interpret the clauses CHECK on this type of data.
The easiest way is to create a field while accepting optimizing partitioned views. For example, the simplest with a partition key for the year is to create a field of type INT containing this information.
Thus, the partition key will no longer be the date field we posed a problem, but the field INT which will be supported without any problems.
I wish I
then discuss the problems of query mode. Indeed, the query optimizer of SQL Server Parameterization of effecting the process before the Planning process the query, SQL Server does not perform the optimizations needed in the following query: DECLARE @
TEST INT SET @ TEST = 50
SELECT Id, PartitionCol VALL FROM WHERE = @ TEST PartitionCol
We can then focus on Dynamic SQL in this specific case, the only solution to get the desired result.
Finally, I wanted to draw attention to the importance of statistics in the connection with the use of partitioned views. Indeed, poor statistics lead the storage of a bad execution plan. Performance will then feel very important, especially in the context of the use of stored procedures, which in case of parameterization of ad hoc queries.
Good evening!
Hi everyone!
After numerous problems with partitioned views, I wish to clarify certain rules to use to avoid problems with these whimsical.
First, I want to talk about the case of date fields used as a partition key. The optimizer of SQL Server is not able to correctly interpret the clauses CHECK on this type of data.
The easiest way is to create a field while accepting optimizing partitioned views. For example, the simplest with a partition key for the year is to create a field of type INT containing this information.
Thus, the partition key will no longer be the date field we posed a problem, but the field INT which will be supported without any problems.
I wish I
then discuss the problems of query mode. Indeed, the query optimizer of SQL Server Parameterization of effecting the process before the Planning process the query, SQL Server does not perform the optimizations needed in the following query: DECLARE @
TEST INT SET @ TEST = 50
SELECT Id, PartitionCol VALL FROM WHERE = @ TEST PartitionCol
We can then focus on Dynamic SQL in this specific case, the only solution to get the desired result.
Finally, I wanted to draw attention to the importance of statistics in the connection with the use of partitioned views. Indeed, poor statistics lead the storage of a bad execution plan. Performance will then feel very important, especially in the context of the use of stored procedures, which in case of parameterization of ad hoc queries.
Good evening!
Subscribe to:
Posts (Atom)