Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE DATABASE [aSchemaCheck]
- GO
- USE [aSchemacheck]
- GO
- CREATE SCHEMA [Aschema] AUTHORIZATION [db_owner]
- GO
- CREATE TABLE ASchema.Name
- (
- time time NOT NULL,
- Name char(10) NULL,
- )
- GO
- CREATE SCHEMA [BSchema] AUTHORIZATION [db_owner]
- GO
- CREATE TABLE BSchema.Name
- (
- time time NOT NULL,
- Name char(10) NULL,
- )
- GO
- CREATE SCHEMA [CSchema] AUTHORIZATION [db_owner]
- GO
- CREATE TABLE CSchema.Name
- (
- time time NOT NULL,
- Name char(10) NULL,
- )
- GO
- $query = "INSERT INTO [$Schema].[Name]
- ([time]
- ,[Name])
- VALUES
- (CONVERT(time,GetDate())
- ,'AName')
- GO"
- Invoke-Sqlcmd -ServerInstance $Server -Database $Database -Query $query
- $Schemas = 'ASchema','BSchema','CSchema'
- foreach($Schema in $Schemas)
- {
- }
- $srv = New-Object Microsoft.SqlServer.Management.Smo.Server $Server
- $db = $srv.Databases[$Database]
- $Schemas = $db.Schemas|Where-Object{$_.IsSystemObject -eq $false}|select Name -ExpandProperty Name
- foreach($Schema in $Schemas)
- {
- }
- $srv = New-Object Microsoft.SqlServer.Management.Smo.Server $Server
- $db = $srv.Databases[$Database]
- $Schemas = $db.Schemas|Where-Object{$_.IsSystemObject -eq $false}|Out-GridView -PassThru|select Name -ExpandProperty Name
- foreach($Schema in $Schemas)
- {
- $query = "INSERT INTO [$Schema].[Name]
- ([time]
- ,[Name])
- VALUES
- (CONVERT(time,GetDate())
- ,'AName')
- GO"
- Invoke-Sqlcmd -ServerInstance $Server -Database $Database -Query $query
- }
- Invoke-Sqlcmd -ServerInstance $Server -Database $Database -InputFile $SQLFile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement