PS: Script to update SQL DB

Below is a PowerShell scripted version of silently updating the SQL DB and saving the SQL query results in a log file.   $sql_file = ‘C:appUpdate-SQLDB.sql’ $sql_log  = ‘C:appUpdate-SQLDB.log’ Add-Content -Path $sql_file  "Update <DBName>..<TableName> set db_database_name = ‘CustomDB_00’ Where db_database_name = ‘AppDefaultDB’" ; Add-Content -Path $sql_file  "Update <DBName>..<TableName> set db_database_name = ‘CustomDB_Trial_00’ Where db_database_name = ‘AppDefaultDB_Trial’" Write-Output "$sql_file" >> "$sql_log" SQLCMD.EXE -U sa -P ‘sapassword’ -S <DBServerName><DBInstanceName> -i $sql_file | out-File $sql_log

Read more

Manually Creating an ODBC DSN Entry

Creating USER DSN via Registry: [HKEY_CURRENT_USERSoftwareODBCODBC.INITEST-SQL-ODBC] "Driver"="C:\Windows\SysWOW64\sqlncli.dll" "Description"="TEST-SQL-ODBC" "Server"="SERVER01\SQLINSTANCE01" "Database"="TrackAsset" "LastUser"="sa" [HKEY_CURRENT_USERSoftwareODBCODBC.INIODBC Data Sources] "TEST-SQL-ODBC"="SQL Native Client" Verifying the creation by registry query: C:>reg query "HKEY_CURRENT_USERSoftwareODBCODBC.INITEST-SQL-ODBC" HKEY_CURRENT_USERSoftwareODBCODBC.INITEST-SQL-ODBC     Driver    REG_SZ    C:WindowsSysWOW64sqlncli.dll     Description    REG_SZ    TEST-SQL-ODBC     Server    REG_SZ    SERVER01SQLINSTANCE01     Database    REG_SZ    TrackAsset     LastUser    REG_SZ    sa1 C:>reg query "HKEY_CURRENT_USERSoftwareODBCODBC.INIODBC Data Sources" /v "TEST-SQL-ODBC" HKEY_CURRENT_USERSoftwareODBCODBC.INIODBC Data Sources     TEST-SQL-ODBC    REG_SZ    SQL Native Client C:>   Creating 32-bit SYSTEM DSN via Registry: [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBC.INITEST-SQL-ODBC] "Driver"="C:\Windows\SysWOW64\sqlncli.dll" "Description"="TEST-SQL-ODBC" "Server"="SERVER01\SQLINSTANCE01" "Database"="TrackAsset" "LastUser"="sa" [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBC.INIODBC Data Sources] "TEST-SQL-ODBC"="SQL Native Client" Verifying the creation by registry query: C:>reg query "HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBC.INITEST-SQL-ODBC" HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBC.INITEST-SQL-ODBC     Driver    REG_SZ    C:WindowsSysWOW64sqlncli.dll     Description    REG_SZ    […]

Read more