Forum Discussion

DebbieE's avatar
DebbieE
Community Champion
6 years ago
Solved

Creating Powershell to run a push data set over SQL DB

I have created a push dataset for real time data straming in Power BI Service   Using the how to guides Im creating Powershell to run it.   However Im getting errors so if anyone knows Powershell...
  • mwegener's avatar
    6 years ago

    Hi DebbieE ,

     

    try this.

    $query = @'
    CREATE @TableName Varchar(200) = ('dim.Realtimedatatestingcustomer');
    DECLARE @MaxUpdateDate DateTime = (SELECT MAX(UpdateDate) FROM [dim].[RealTimedatatestingcustomerDE]);
    DECLARE @OldUpdateDate DateTime = (SELECT ISNULL([UpdateDate],0) FROM audit.RealTimeDataAudit WHERE TableName = @TableName);
    
    
    UPDATE audit.RealTimeDataAudit
    SET [UpdateDate] = @MaxUpdateDate
    WHERE TableName = @TableName;
    
    SELECT [CustKey], [Name], [UpdateDate] FROM [dim].[RealTimedatatestingcustomerDE]
    WHERE [UpdateDate] = @MaxUpdateDate; '@

     

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7