Converting bigint [closed] - sql-server

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I want to convert this bigint for Ex: 637194307500000000 using Microsoft sql server. I have tried
SELECT DATEADD(S, 637194307500000000, '19700101')
I am getting arithmetic overflow error.

SQL Server cannot represent a time that large. If, perhaps you mean 6,371,943,075 seconds, then you could switch to minutes instead:
SELECT DATEADD(MINUTE, 6371943075 / 60, '19700101')
This produces the result 2171-12-02 08:11:00.000, which itself seems a bit unlikely.

Related

Why operator AND returns error in tsql, that seems to be valid in general sql [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I try to apply WHERE AND WHERE operators, but somehow AND returns an error, single WHERE for both cases works fine.
I don't feel like I made a mistake in code as well, at least not in general SQL syntax.
SELECT *
FROM dbo.flat_file
WHERE [Date] > '1/1/2020'
AND
WHERE [Deposit] > 1000
I am new to T-SQL, so I may not be aware of basic principles.
tsql printscr
There can only be one WHERE clause in a query. You try to have two. Instead just AND the second condition to the first in the first (and only) WHERE clause.
SELECT *
FROM dbo.flat_file
WHERE [Date] > '1/1/2020'
AND [Deposit] > 1000;
Side note: varchar is likely the wrong datatype for date and deposit. date and integer my be a better fit.

Round up with ceiling in SQL server [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have to increase by 3% and round up the prices I have in a table. My script:
UPDATE tbl_products
SET Prices = CEILING(prices * 1.03, 0)
After I run the script, SQL Server Management Studio returns an error, saying:
ceiling function requires one argument.
If I use ROUND instead of CEILING, the script works great. What I'm doing wrong?
Syntax is as shown below. Ceiling() function is used to find the smallest integer value.
CEILING( number )
Here is an example.
SELECT CEILING(32.65);
Result: 33
SELECT CEILING(32.1);
Result: 33
SELECT CEILING(32);
Result: 32
SELECT CEILING(-32.65);
Result: -32
SELECT CEILING(-32);
Result: -32

How to convert this MS SQL numeric value to a date [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Should be an easy convert, but cast and convert are failing me.
The value I am trying to convert is: 1509180600
Other examples are 1572256200, 5150938920
I have a very large number of records and many fields where dates have been stored like this. The system is being replaced, which means thankfully, this problem will go. But need to know what the values are before wiping them!
This is probably a Unix timestamp. You can convert it by adding seconds to 1970-01-01:
select dateadd(second, col, '1970-01-01')
. . .

SQL, Case When returning the incorrect results [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
This error is starting to tick me off so im posting pictures instead sorry......
In SQL, the expression some-value = NULL always returns NULL, which is logically a lot like false. What you want is some-value IS NULL

String or binary data would be truncated. in sql server while insert statement [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have table structure as below..
but while running insert statement to it shows
error..
INSERT INTO ORD_MST
(ORM_FRCD,ORM_ORID,ORM_MBID,ORM_ORQT,ORM_ORDT,SL_CD)VALUES
('LYM11111111','000174','LYM11111111',2,'01/01/2009','123')
Your ORM_FRCD field has length of 10 and you're trying to insert 11 characters.
The values you are inserting must be within the character_maximum_length values

Resources