User Profile
HarshKumar994
Brass Contributor
Joined Dec 21, 2022
User Widgets
Recent Discussions
Re: update the records
Bhavsing Its better to have an identity column or a column with a Primary key. Identity Column -> In SQL Server, an identity column is a special type of column that is commonly used as the primary key of a table. An identity column is a column whose values are generated automatically by the database system, typically incrementing by 1 for each new row added to the table. The purpose of an identity column is to provide a unique, sequential number for each row in the table. Example - CREATE TABLE my_table ( id INT IDENTITY(1,1) PRIMARY KEY, name VARCHAR(50), age INT ); Update Statement - UPDATE my_table SET my_column = 'new_value' WHERE my_column = 'old_value'; You can manually update the same via GUI as well. Hope it's clear------- If yes, reply and hit like ----- If not reply with your query in more detail----1.7KViews1like0CommentsRe: About SQL 2016's patch
You have installed "KB5015371 Security update for SQL Server 2016 SP3 Azure Connect Feature Pack: June 14, 2022 CVE-2022-29143" that automatically covers all the older CUs. For your understanding. How CUs work - Installing the latest cumulative update (CU) for SQL Server will include all the fixes and updates from the previous CUs. Therefore, you do not need to install all previous CUs one at a time if you are installing the latest CU. For example, let's say you have SQL Server 2019 installed and you want to apply the latest CU, which is CU13. CU13 will include all the fixes and updates from previous CUs, such as CU1, CU2, CU3, and so on. So, you can directly install CU13 without the need to install any of the previous CUs. However, if you have skipped one or more CUs and you want to apply a specific CU, then you should install all the previous CUs that you have skipped before installing the specific CU. For example, let's say you have SQL Server 2019 installed with CU10 installed, and you want to apply CU12. In this case, you should first install CU11 (as it includes all the fixes and updates from CU10) and then install CU12. ----------Hope it's clear------- If yes, reply and hit like ----- If not reply with your query in more detail-----1.3KViews1like1CommentRe: Can I copy the script from the Execute T-SQL statement Task in a maintenance plan (MP)
* When you create a maintenance plan, a job is automatically created in SQL Server Agent under Jobs. So now go to SQL Server Agent, expand jobs, and look for your job. Right click on it and select Script job as... Drop and recreate to... New query editor window. You can use the following options to return a list of SQL Server Agent jobs with T-SQL: Option 1: Execute the sp_help_job stored procedure. Option 2: Query the sysjobs_view view. Option 3: Query the sysjobs table directly. * ==========Powershel Script to Export all SQL Agent Jobs =============== [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo') | Out-Null $serverInstance = "InstanceName" $server = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $serverInstance $jobs = $server.JobServer.Jobs #$jobs = $server.JobServer.Jobs | where-object {$_.category -eq "[your category]"} if ($jobs -ne $null) { ForEach ( $job in $jobs ) { $FileName = "D:\HarshKumar\SQLServerAgentJobs\" + $job.Name + ".sql" $job.Script() | Out-File -filepath $FileName } } ============================== * You can export the maintenance plans as well. You need to connect to Integration Services of the instance. Expand the stored packages then MSDB then expand Maintenance plans. Right click on MP and select a export package. Then you can move the package to another SQL Server. As per my knowledge we can't directly script out Maintenance Plans in SQL Server.1.2KViews0likes0CommentsRe: SQL 2019 Fails to Start - Error 17051
The error indicates that you have used the evaluation edition and it got expired (completed 180 of Trial). If your upgrade via GUI is failing - You can try another approach if process fails at Engine_SqlEngineHealthCheck step or anywhere in between, then you can use following command line installation option to skip this specific rule to allow the upgrade process to complete successfully: a) Open Command Prompt (CMD) b) Go to the folder where SQL Server Setup, setup.exe file is located (like C:\Program Files\Microsoft SQL Server\***\Setup Bootstrap\SQLServer20**\) c) Apply following command: setup.exe /q /ACTION=editionupgrade /InstanceName=MSSQLSERVER /PID=<appropriatePid> /SkipRules= Engine_SqlEngineHealthCheck The <appropriatePid> should be the 25 digit Key. The above command line runs SQL Server setup in silent mode. 5. Now Restart the SQL Server Service for this Instance, and you will see it running fine.41KViews0likes0CommentsRe: SQL Backups failing on SharePoint Search_Service_Application_AnalyticsReportingStore
Have you tried changing the owner of the job to SA, if not try changing to SA. For more detail on EventID 208 you can refer the below link. https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-208-database-engine-error?view=sql-server-ver16970Views0likes0CommentsRe: I want to explore the possibilities of updating SQL table with Microsoft form whenever a response is
You can achieve the same via many ways. One of them could be - 1. Create a new Microsoft Form to collect the necessary production details. 2. Create a new Excel spreadsheet and link it to the Microsoft Form to store the submitted data. 3. Connect to the Excel spreadsheet as a data source in your SQL Server. 4. Create a SQL Server Integration Services (SSIS) package to extract data from the Excel spreadsheet and load it into the SQL table. Let me know if it suits your requirement. If you are satisfied with the answer hit like button.1.5KViews0likes0CommentsRe: Can I copy the script from the Execute T-SQL statement Task in a maintenance plan (MP)
Can you elaborate more it's kind of unclear requirement. If you wanted to take backup of all databases, you can achieve it via Maintenance plan. If you want to execute the script via maintenance plan you can achieve the same.1.2KViews0likes2Comments- 1.3KViews0likes0Comments
Re: Removing any output from BACKUP operation on SQL Server
There is no built-in option to suppress the backup completion message entirely in SQL Server. However, you can redirect the output of the backup command to a text file or a null device to prevent the messages from being displayed on the console output. Here is the query you can try. BACKUP DATABASE myDB TO DISK = 'C:\Backup\myDB.bak' WITH INIT, SKIP, STATS = 100 > C:\Backup\BackupLog.txt This command backs up the "myDB" database to the "C:\Backup\myDB.bak" file, skips any existing backup sets, generates progress messages every 100 percent, and redirects the output to a text file named "BackupLog.txt" in the "C:\Backup" folder. Note that the > symbol is used to redirect the output to a file. If the file already exists, the new output will be appended to the end of the file. If you want to overwrite the file each time the command runs, you can use >> instead of >like below. BACKUP DATABASE myDB TO DISK = 'C:\Backup\myDB.bak' WITH INIT, SKIP, STATS = 100 >> C:\Backup\BackupLog.txt1.6KViews0likes0CommentsRe: What is the difference between OPTIMIZE FOR (@variable = value OR @variavel UNKOWN)
OPTION(OPTIMIZE FOR (@dtini UNKNOWN, @dtfim UNKNOWN)) tells the query optimizer to optimize the query plan for unknown parameter values, meaning it will try to generate a query plan that will perform well for any parameter value that is passed in. This can be useful when the query is expected to be run with a variety of different parameter values. On the other hand, OPTION(OPTIMIZE FOR (@dtini = '2023-01-06', @dtfim = '2023-01-06')) specifies specific parameter values to the query optimizer. This tells the optimizer to generate a query plan specifically optimized for the values '2023-01-06' that are passed in for @dtini and @dtfim. This can be useful when you know the specific parameter values that will be used for the query, and you want to ensure that the query is optimized for those specific values.2.9KViews0likes0CommentsRe: create table with one column from two fields min and max date from another table
Consider you have an Order table CREATE TABLE orders ( order_id int PRIMARY KEY, order_date date ); We can create a new table called "date_range" with one column "range" that contains the minimum and maximum order dates from the "orders" table using the following SQL statement: CREATE TABLE date_range ( range daterange ); INSERT INTO date_range (range) SELECT daterange(MIN(order_date), MAX(order_date)) FROM orders;1.1KViews0likes0Comments
Recent Blog Articles
No content to show