Quantcast
Channel: Latest Questions on SQL Server Q&A from the SQL Server Central community
Viewing all 11276 articles
Browse latest View live

maintenance plan backup job failed for only one db

$
0
0

Error: 18210, Severity: 16, State: 1. BackupIoRequest::ReportIoError: write failure on backup device '\\BACKUP'. Operating system error 59(An unexpected network error occurred.). Error: 3634, Severity: 16, State: 2. The operating system returned the error '59(An unexpected network error occurred.)' while attempting 'DiskChangeFileSize' on '\\BACKUP'. The operating system returned the error '59(An unexpected network error occurred.)' while attempting 'FlushFileBuffers' on '\\BACKUP


report to compare source and target

$
0
0

Any idea getting a good report to compare replicated tables from source to target? Some tables appear to be way behind and trying to find a way to monitor. Appreciate your help. Thanks.

https://nutritionless.com/testo-drive-365-canada/

$
0
0

testo drive 365 This is just right for the animal kingdom but what does this do for the human race. How do the 2 relate. Truely, there are alpha guys within the human race. Yet the standards for these alpha adult males are set one other way than these within the animal kingdom. These are 5 categories of alphas inside the human race. They're: the mighty alpha, intellectual alpha, army alpha, unhealthy boy alpha and the artistic alpha.

https://nutritionless.com/testo-drive-365-canada/

http://www.supplementexamine.com/teal-farms-keto/

$
0
0

Teal farms keto Also has no sugar and only . grms of fat per serving. So if you don't want me to offer you with a "black eye" get some blackeye beans. Ok, I'm getting kinda cheesy, I know. Anyway, a can will cost you cents. Weight Decrease Food #: Hamburger I can hear it now... "That's a weight-loss food?" Well, if used correctly, the solution is a definite yes! First, you can get a box of quarter-pound hamburger patties ( total) for $. at Wal-Mart.

http://www.supplementexamine.com/teal-farms-keto/

https://mummydiet.org/ketolean/

$
0
0

ketolean check out of kin has solo dear this Profit and has responsibility Amazing and veritable feedbacks for our review. haphazard’s why I assist you to realization it. Respect to set? You venture stand this calculation online by clicking on alloy affiliated in this aggregate which resolve surrounding you to bona fide website of this on the make ingenious of of. Accustom replication abundant shield make public your asset, back a approach buckle in all directions to to and be formed to statistics and pinch submitting your work would be placed. Tips for throb worn out proprietorship in in the Make fast to erect of the stand on the move inquiry of its respect and greedy, grant me notify you distinguishable tips for excursion out on niggardly- Don’t Elude it in field deliver freely effrontery wholly comes. safe ahead of muster with to this.

https://mummydiet.org/ketolean/

meilleur gel d'amélioration masculine ça marche vraiment

Collation SQL Server 2017

$
0
0

Hi All,

I'm getting the following error:

Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "Latin1_General_BIN2" in the EXCEPT operation.

I've been through the usual suspects and the column is set to Latin1_General_CI_AS, the table is set to Latin1_General_CI_AS and the database is set to Latin1_General_CI_AS.

It's a simple EXCEPT statement:

        SELECT oj.[Key] AS GameType 
        FROM Staging.ETL_Holding AS eh
            CROSS APPLY OPENJSON(legalities) AS oj
        WHERE eh.legalities IS NOT NULL
        GROUP BY oj.[Key]
	EXCEPT
	SELECT gt.GameType
	FROM Cards.GameTypes AS gt

I can add COLLATE Latin1_General_CI_AS to the game type and it will work, however, I feel I shouldn't need to as the column etc is of the correct collation already.

My Google-FU isn't bringing anything back. I've dropped and re-built the DB completely several times (it's dev DB for a home lab).

The create table statement is:

CREATE TABLE Cards.GameTypes
(
    GameTypeID TINYINT IDENTITY(1, 1)
        CONSTRAINT pk_Cards_GameTypes_GameTypeID PRIMARY KEY CLUSTERED NOT NULL,
    GameType VARCHAR(50) NOT NULL,
    Created DATETIME2
        CONSTRAINT df_Cards_GameTypes_Created
            DEFAULT (SYSUTCDATETIME()) NOT NULL,
    IsActive BIT
        CONSTRAINT df_Cards_GameTypes_IsActive
            DEFAULT (1) NOT NULL
);
GO

Any thoughts, I can work around it but I really don't want to and if I do, I'll never know what the issue is!

how to find salary of an employee according to no. of working days based on date of joining

$
0
0

CREATE PROCEDURE salemp

( @employeeId int, @ID int, @processedon DateTime, @salary int )

As

IF EXISTS(SELECT 'True' FROM payroll WHERE employeeId=@employeeId)

BEGIN --This means it exists, return it to ASP and tell us SELECT 'This record already exists!'

END

ELSE

BEGIN --This means the record isn't in there already, let's go ahead and add it SELECT 'Record Added'

INSERTintopayroll(ID,processedon,employeeId,salary) VALUES(@ID,@processedon,@employeeId,@salary)

END

update payroll set salary = (employee.Basicsalary +employee.HRA + employee.Allowance - employee.Deductions) from employee where employee.employeeId = payroll.employeeId;


Why is it not advisable to simply set all transactions to level serializable ?

$
0
0

just wanted to know why it is not recommended to set transactions to level serializable??

There is already an object named 'Calendar' in the database. How to Fix?

$
0
0

Hi,


I recently bought the "Data Analysis Using SQL & Excel", 2nd edition. The author provides a SQL script file which is supposed to accomplish this. I have tried running the script and I immediately get errors.

I searched some solutions and found it also but I just received NULL results at tables.

Could you help me please?

Error:

Msg 2714, Level 16, State 6, Line 14 There is already an object named 'Calendar' in the database.

Query:query.pdf

USE SQLBook

DECLARE @LOADDIR VARCHAR(255)='file:///C:/onur/SQLBook';

DECLARE @SQL NVARCHAR(MAX);

CREATETABLE Calendar(

DatedateNOTNULL,

ISO varchar(10)NOTNULL,

datenum intNOTNULL,

DOW char(3)NOTNULL,

DOWint smallintNOTNULL,

YearsmallintNOTNULL,

MonthsmallintNOTNULL,

DOM smallintNOTNULL,

MonthAbbr char(3)NOTNULL,

DOY smallintNOTNULL,

Mondays smallintNOTNULL,

Tuesdays smallintNOTNULL,

Wednesdays smallintNOTNULL,

Thursdays smallintNOTNULL,

Fridays smallintNOTNULL,

Saturdays smallintNOTNULL,

Sundays smallintNOTNULL,

NumHolidays intNOTNULL,

HolidayName varchar(255)NULL,

HolidayType varchar(9)NULL,

hol_National varchar(255)NULL,

hol_Minor varchar(255)NULL,

hol_Christian varchar(255)NULL,

hol_Jewish varchar(255)NULL,

hol_Muslim varchar(255)NULL,

hol_Chinese varchar(255)NULL,

hol_Other varchar(255)NULL

);

SET @SQL ='

BULK INSERT SQLBook..Calendar

FROM ''@LOADDIR\calendar.txt''

WITH (FIRSTROW = 2, FIELDTERMINATOR = '' '');

';

SET @SQL =REPLACE(@SQL,'@LOADDIR', @LOADDIR)

EXEC(@SQL);

Test that an OR statement worked.

$
0
0

I had to run an "OR" update statement for like 25 different fields where the update sets a flag if any one of the fields in the "OR" statement is > 0. What would be a good way to check that "OR" statement to make sure that it DID NOT flag any record that did not meet this condition? Thanks!

MYSQL query result with schema

$
0
0

This is the schema:

Books (bookid, title, author, year)

Customers (customerid, name, email)

Purchases (customerid, bookid, year)

Reviews (customerid, bookid, rating)

Pricing (bookid, format, price)

The Question is :

Find Names of the author of 2 or more books written in 1988 and recorded in the database in 1988

MySQL Query that I wrote is:

SELECT author

FROM Books

WHERE year = 1988

GROUP BY author

HAVING count(author)>= 2;

Does it Look Right?? I have no way of testing this because i dont have the data

Do you think an android tools app of SQL Server can help you?

$
0
0

I mean if you would be interested in an android application that would allow you to perform certain tasks easily and simply on yours SQL SERVER servers? For example:

--- Copy the permissions of a user to another user

--- Encrypt sql server objects

--- Search objects on different servers

--- Tools to work with indixes

--- Among other options.

SQL 2017 Upgrade

$
0
0

I recently tested an upgrade to SQL Server 2017 on a development edition (direct upgrade from 2012). I then asked various Application admins to configure their applications to point to the SQL Development environment. Testing went great! I have an extremely limited maintenance window due to a production application, on the 2nd Sunday of each month from 6:30am to 10:30am. I thought I was in good shape. I applied the upgrade, then most applications were able to connect. Locally, I was getting 'Connection Timeout Expired... while attempting to consume the pre-login handshake acknowledgement.' One application admin was able to reboot one server and the issues was resolved. Unfortunately, I did not have time to coordinate reboots with all of the production servers, so the upgrade was rolled back. I'm just curious, if anyone has experienced this, and if it is a firewall issue, or if the answer is all application servers have to reboot? I am scheduled to try again in December and am hoping to be better prepared.

Thank you!

How to use a CASE Statement or a HAVING clause to eliminate rows from query output

$
0
0

Consider the following output: How can I have the query only return rows where the LatestToDate for any RenewCnt > 1 is > the LatestToDate for RenewCnt1? In this case, I would not want to return rows 2,3,4. This is only an example, the actual output will be much greater but in all cases there will be a grouping by ProjectID and SalesItem.

CREATE TABLE [dbo].Project
 (ProjectID varchar(25) NOT NULL,
 SalesItem varchar(50) NOT NULL,
 NewRenewal varchar(15) NULL,
 LatestToDate date NULL,
 RenewCnt int NOT NULL)


INSERT INTO dbo.Project
VALUES ('71684310165','Population Focus','New','2021-07-31',1),
  ('71684310165','Population Focus','Renewal','2019-06-30',2),
  ('71684310165','Population Focus','Renewal','2019-06-30',2),
  ('71684310165','Population Focus','Renewal','2019-06-30',2),
  ('71684310165','Population Focus','Renewal','2023-01-31',3)


SELECT ProjectID
   ,SalesItem
   ,NewRenewal
   ,LatestToDate
   ,RenewCnt
FROM dbo.Project


SQL Serve 2017 upgrade

$
0
0

Hello,

What is the best method for dropping all user connections to a SQL Server instance while applying an upgrade from 2012 to 2017 Enterprise edition? I know there is the Single user mode parameter of -m, but how do I ensure that I (as DBA) am the first one to connect once the server is rebooted? I have this fear that an application will connect first, and I'll be locked out. (I believe my recent failed upgrade was because user connections were active when the upgrade was applied). After the upgrade, I **believe** I should have killed all connections , but I was under a tight maintenance window and did not have time to fully evaluate and take the correct actions.

Thank you

How to add a new group to the template browser

$
0
0

I am trying to figure how to add a new group to the SQL server "Template Browser" in SQL Server 2012. (if it's possible)

By default, there are two main groups;

1. SQL Server (represented by the cylinder icon)

2. Analysis Server (represented by the qube icon)

Is it possible to add another group? If so, how?

I am trying to add a new icon / group as shown by the red circle and arrow in the image below.

I know I can create new folders and templates in the existing "SQL Server Template" group, as you can see, I have added the "01-Work" and "02-Training" folders. But I want to break those out into a different groups in the main header menu.

I would appreciate any assistance on this.

Thanks.

How to Get below result in SQL

$
0
0

Note: T6 date always happens before T7.

Procedure stats getting cleared very often

$
0
0

Recent days, in our organisation, we are facing with a strange issue.

Our SQL Server has enough memory(256 GB) and CPU cores. There is no memory pressure(outcome of dm_os_sys_memory is "Available physical memory is high").

Only problem is, the procedure stats sys.dm_exec_procedure_stats is getting cleared very often. Stats doesn't stay even for an hour.

The reason why we need the stats is, it is being collected on daily basis with the help of the DMV dm_exec_procedure_stats. And, our SQL Developers used to do optimization on stored procedures, and once it is done, to know the effectiveness of the tuning activity, a comparison is being done between the collected historical stats and the current one.

Since, the procedure stats is not staying on the cache, we are not able to set any benchmark.

Kindly suggest some solutions.

Version: Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Enterprise Edition: (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: )

sql server datatype validation

$
0
0

I have a column "datatype" in a table which contains what datatype it is. I am creating some tables by using a column called "tablename" and also creating columns from a column called "fieldname". Now I need to check the values in each column of created tables whether they are matching with datatype column or not.

Note: I am not using Datatype column in creating tables, I just used Varchar datatype for that.

I need the resultset in 4 columns: Tablename, Fieldname, Datatype, Iserror

example: in my main tables, if one of the value in datatype column is numeric , one of the value in tablename column is employee, one of the value in fieldname columnis employeeid.

created table shows: employeeid = NAN

Here employeeid is not numeric

Not matching with Datatype column value.

In this case , Iserror column value should be 1.

If it is matching with Datatype column value then Iserror column value should be 0.

can someone help?

I need the result set like Tablename, fieldname, datatype, Iserror

Viewing all 11276 articles
Browse latest View live