Hi there,i am having problems enumerating the jobhistory for SQL-Server 2008 SP1 (10.00.2531).On SQL-Server 2008 R2 and 2012, everything works fine, and the function returns a DataTable-Object. Connected to SQL-Server 2008 SP1, the function call "hangs" and does not response anymore... till i kill the process manually.Any hints on that?
↧
C# => EnumJobHistory() not working on SQL-Server 2008 SP1 (10.00.2531) with smo-dll 11.0.0.0 and 10.0.0.0
↧
Problems connecting to SQL Server 2012 using 2005 SMO
Should 2005 SMO be able to access SQL 2012 please?We are currently performing a large migration to SQL Server 2012. It's been going well, but we have hit a problem testing an app. An app server is throwing an exception "This SQL Server version (11.0) is not supported". On further investigation an internal library (used potentially in a number of places) is found to be using Microsoft.SqlServer.ConnectionInfo 9.0.242.0.Testing seems to show that referencing a later library works. Is this expected behaviour that 2005 SMO library can't access SQL 2012? What are our options - the dev teams are nervous of installing a later version and changing this internal library to reference it (although tests have shown this works). Any simple ways around it? regards
↧
↧
Replication between two SQL 2012 Express DBs using SMO
Hi There,I have two MSSQL Express 2012 databases each on separate machines (one for live LAN Data and the other for external IP access by a website for security reasons)I've read that SQL Express 2012 can only use replication as a subscriber and since the client does not have the resources (or inclination) to purchase a full standard license simply for Replication, I thought of using an SMO enabled vb.net windows service to periodically transfer changed data from one Express DB to the other...My question is two fold:1) Is this the best way to do this (bar purchase of a full SQL license)?2) What crucial considerations are there and what approach would be most suited? (I'm assuming RMO would not work between 2 Express versions)I was thinking along the lines of either making a backup and restoring it periodically or copying entire tables periodically or should I rather compare tables and add new records individually as they get added? (I have a timestamp on records indicating creation and last edit)Since I've never approached this before, your invaluable expertise would be very much appreciated :-)Kind Regards,Riaan
↧
Powershell SMO works in cmd, not from script
Hope this is a correct forum.My code (Server 2003 Enterprise, SQL Server 10.0.5512.0, Powershell v1.0 ISE) is as follows:function Script-Database_01 { # Created: 09/06/2013 # Edited: 09/06/2013 [CmdletBinding()] param( [Parameter( Mandatory=$true, ValueFromPipeline=$true, HelpMessage="Local directory to save build-scripts output.")] [Alias('fp')] [string[]] $Filepath, [Parameter( Mandatory=$true, ValueFromPipeline=$true, HelpMessage ="Server or instance name.")] [Alias('ds')] [string[]] $DataSource, [Parameter( Mandatory=$true, ValueFromPipeline=$true, HelpMessage="The database to be scripted.")] #[Alias('db')] [string[]] $DatabaseName ) BEGIN{ Write-Output $Filepath Write-Output $DataSource Write-Output $DatabaseName Get-PSSession } PROCESS{ # Set 'Option Explicit' to catch subtle errors: set-psdebug -strict #Load SMO assembly, and SMOExtended and SQLWMIManagement libraries: $ms = "Microsoft.SqlServer" $v = [System.Reflection.Assembly]::LoadWithPartialName("$ms.SMO") [System.Reflection.Assembly]::LoadWIthPartialName("$ms.SMOExtended") | out-null $my = "$ms.Management.SMO" $source = new-object("$my.Server") $DataSource if ($Source.Version -eq $null) {Throw "Cant find the instance $DataSource."} $db = $source.Databases[$DatabaseName] if ($db.name -ne $DatabaseName) {Throw "Cant find the database '$DatabaseName' in $DataSource."} $transfer = new-object("$my.Transfer") $db $transfer.Options.ScriptBatchTerminator = $true # This only goes to file $transfer.Options.ToFileOnly = $true # This only goes to file $transfer.Options.Filename = "$($Filepath)\$($DatabaseName)_Build_01b.sql" # Do it: $transfer.ScriptTransfer() } END{}}When I execute everything in the PROCESS{} section, the commands succeed, and the file is correctly output. When I run the script (as .\Script-Database_01.psq [+parameters] I get the follow error:New-Object : Cannot find an overload for "Server" and the argument count: "2".At C:\Powershell\Scripts\Script-Database_01.ps1:44 char:29+ $source = new-object <<<< ("$my.Server") $DataSource + CategoryInfo : InvalidOperation: (:) [New-Object], MethodException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommandI assume this has something to do with the import of SMOExtended, but I can't see it.Can anyone point me in the "write" direction?
↧
Idea to simply inform Admin when values are found in SQL-Table by mail, maybe with Notify operator task
Hello,I have found some situations, where values appear in Column NDF_STATUS in database table NDF_AUFTRAG. This can be normal. It is only critical, when these values exceed a limit I_MAXERRORS. I would like to inform the admin of the application, using this table by mail. He is the one who also gets other notifications when e.g. the database backup has failed, so an operator is available.My idea was to check each hour (is enough) if there are more than I_MAXERRORS data rows with criteria:I have a function giving me the test-result:CREATE FUNCTION [dbo].[ERROR_IN_NDF_AUFTRAG] ( ) RETURNS intASBEGINdeclare @I_COUNT_ERRORS as intdeclare @I_MAXERRORS as int=5set @I_COUNT_ERRORS = (select Count (*) from NDF_AUFTRAG where NDF_STATUS between 1 and 9) if @I_COUNT_ERRORS<@I_MAXERRORS begin return 0 end return 1ENDDo you see a simple way to do this?
↧
↧
Check file list inside a backup file
I'm trying to get the list of database names / files from a backup file. Here's the code: [code="vb"] ''' <summary> ''' Prepare a RESTORE2 object. ''' </summary> Private Shared Function CreateRestoreObject(filePath As String, Optional forRestore As Boolean = False) As SQLDMO.Restore2 Dim res As New SQLDMO.Restore2() ' What to restore res.Action = SQLDMO_RESTORE_TYPE.SQLDMORestore_Database ' Input data res.Files = "[" + filePath + "]" ' Protection (?) password res.Password = SLQBackupPassword If forRestore Then res.ReplaceDatabase = True res.PercentCompleteNotification = 10 End If Return res End Function Dim objRestore = CreateRestoreObject(filePath) Dim hdrList = objRestore.ReadBackupHeader(srv) Dim nameList = GetQueryResultList(hdrList, "DatabaseName") [/code]The code works fine on a SQL Server backup, but fails with a "***Password protected***" string on SQL Server Express backups. The corresponding SQL statement[code="sql"]RESTORE HEADERONLY FROM DISK = N'...' WITH FILE = 1, NOUNLOAD , PASSWORD = N'...'[/code] works correctly. What am I doing wrong?
↧
Using SMO to move tempdb
I'm trying to improve my SQL Server Instance configuration scripts using SMO.This includes moving TempDB to a new location, ie. the equivalent of:[quote]ALTER DATABASE tempdbMODIFY FILE (NAME = tempdev, FILENAME = 'D:\NewTempDBhome\tempdb.mdf');GOALTER DATABASE tempdbMODIFY FILE (NAME = templog, FILENAME = 'D:\NewTempDBhome\templog.ldf');GO[/quote]However I cannot find a way to do this using SMO (in PowerShell).I have attempted to use something like the following:$smo = New-SMOconnection 'Win2012R2_A\SQL2014'$smo.databases["TempDB"].LogFiles[0].Filename = <New location>$smo.databases["TempDB"].LogFiles[0].Alter()But it fails. I [strike]expected[/strike] hoped to find some [i]MoveMyDatabaseFile()[/i] method, but apparently non exist.Any suggestions?
↧
SMO Missing properties
I have a server that seems to be missing some properties when accessing via SMO in powershell, specifically the default data and log file locations. These can be viewed through ssms and tsql. Has anyone encountered this before?
↧
A SQL Sever Script Generator Utility
SQL server generates scripts task does not have the option to filter by object name. It is impossible to manually select hundreds of SQL objects manually especially you need choose a subset of objects from an entire database.I created a simple utility to generate scripts using SMO from .NET 4.0. Obviously it can not cover all options. Here is a list of objects and options included in the generating process.Find details from My blog.[url=https://lisql.wordpress.com/2015/05/25/sql-script-generator/]https://lisql.wordpress.com/2015/05/25/sql-script-generator/[/url]
↧
↧
Can I use SMO to script out schema objects from a database ?
Hello all,we have a couple of databases that have constant data change capture on them,without going in much detail it is allmost impossible storage wise to keep a consisten databackup on these & we don't really need one as the source system already has those if needed.However we need to maintain the structure so each week we want to run something that will generate an sql script for all the objects in the database.I have a script that does that,tested out very nicely,only got 2 issues left to resolve,getting the users & getting the schema.For instance we can have tables abc.def or def.abcI need to have the create script for abc. & def.I followed most of the stuff I could find about smo but when I try the schema's I get the following error[code]Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Discover dependencies failed. ---> Microsoft.SqlServer.Management.Smo.InternalEnumeratorException: Schema is not supported in dependency discovery. Only objects of the following types are supported: UserDefinedFunction, View, Table, StoredProcedure, Default, Rule, Trigger, UserDefinedAggregate, Synonym, UserDefinedDataType, XmlSchemaCollection, UserDefinedType, PartitionScheme, PartitionFunction, SqlAssembly.[/code]Is their a way around this issue.PSI'm making this in C# a language I had 0 experience with yesterday.
↧
Got a newbie SMO powershell question/issue.
Hello everyone,I'm quite new to PowerShell, but getting along OK with a PS cookbook, but I have run into an issue and I cant get around it, and looking for some help.I just wanted to list the service accounts, it all looks good but I am getting the following error when I run it which I am fairly sure relates to $managedcomputer.servicesPS SQLSERVER:\> $managedComputer.ServicesThe following exception occurred while trying to enumerate the collection: "SQL Server WMI provider is not available on MyNamed\instance.".At line:1 char:1+ $managedComputer.Services+ ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : ExceptionInGetEnumeratorI did import the module SQLPS, and their are no problems with that. My actual code is...#import SQL Server ModuleImport-Module SQLPS -DisableNameChecking$InstanceName = "MYNAMED\INSTANCE"$managedComputer = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' $InstanceName#ListServices$managedComputer.Services | Select Name, ServiceAccount, DisplayName, ServiceState | Format-Table -AutoSizeSo I downloaded the SQL 2012 Feature Pack to get the SQLSysClrTypes, SharedManagementObjects, and PowerShellTools, which google led me to from the error I was receiving, and now face an additional issue whereby I cannot install the sharedmanagment objects because it says I need to install the SQLSysCLRTypes as a prerequisite, buts already installed. I also tried uninstalling, and also tried the 32 bit options.I'm enjoying learning PS, but this is just a pain. I am running it within the ISE in case its important.Any advice? PowerShell V3 BTW.Thank you.Regards,D.
↧
Cops talk man off bridge by discussing
[url=https://www.youtube.com/watch?v=0R_QUYpFStw]Florida State vs Louisville Live Streaming[/url][url=https://www.youtube.com/watch?v=grhxPaszRXw]Tennessee vs Ohio Live Streaming[/url][url=https://www.youtube.com/watch?v=tWFpV63KjxE]Clemson vs South Carolina State Live Streaming[/url]
↧
object with managedDTS
hi, I try to create this object, but I Had error :$obj= new-object Microsoft.SQLServer.ManagedDTS "$ServerName"error - "can't find type [ Microsoft.SQLServer.ManagedDTS ] : make sure the assembly containing this type is loaded "thank's for the help.
↧
↧
update access to sql server
I would like 'power' users to be able to run queries and update selected tables, I would prefer for this to occur on the web. Can you tell me how to accomplish this task using either sql server 2005 and/or sql server 2008 R2?
↧
load assembly - error
hi,
I load assembly of managedts.
it's work great with the new version of sql 10.5 .
but when I try to use this spesfic assembly I get a ERROR Version.
mybe someone had exprience about this.
thank's
↧
SMO within SSIS Script Task - User.Drop() causes error at runtime.
I am having issues with the following code within a SSIS package. It is designed to drop all database users before a restore operation commences and following a kill all connections script. The issue I am running into is that at run-time this code gener
↧
Growth of transaction log
someone has script to monitor a Growth of transaction log in sqlserver/
or link.
thank's
↧
↧
ListAvailableSQLServers (SQL-DMO) deprecated
I understand that ListAvailableSQLServers is deprecated, but I cannot find what to replace it with.
I see that SQL-DMO is replaced with SMO, but I do not see an equivalent method. code snippet below.
Assistance greatly appreciated.
SQLDMO.NameL
↧
smo table script generation performance problem
Hello,
I'm currently working on program for database compare. In this program I need to create scripts for databse objects. i found out that script generation is too slow but generating scripts using SSMS it's pretty fast. In one thread I have found, tha
↧
SMO performance issues!
Hi guys!
I've used SMO in some my latest apps but I am really disappointed with performance! It is horrible slowly!
Did you felt this issues also?
What do you think!
↧