How to check if one table is replica of other table in SQL? [closed] - sql

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 7 years ago.
Improve this question
How to find if one table is replica of other table in SQL

In SQL Server, you can compare the results of:
SELECT checksum_agg(checksum(*))
FROM Table1;
SELECT checksum_agg(checksum(*))
FROM Table2;
You could create a join with these as sub-queries if you want, too.
You may wish to use binary_checksum() instead of checksum(). The doc says that checksum() will treat strings that are equal as equal according to the collation (i.e., 'hello' and 'HELLO' if the collation is case-insensitive), while binary_checksum() compares the raw binary values of characters.

This works for MySQL:
CHECKSUM TABLE table_1, table_2;

Related

Is there any way to put WHERE filter inside the SELECT statement in SQL? [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 last year.
Improve this question
I got a task that i need to know how can i put WHERE clause inside the SELECT statement (like SELECT .... WHERE.... FROM...) . hope you guys could help me. thank you :)
'Where' is used to filter the data based on a condition.
The general syntax is:-
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Here you can get a better overview.

regexp_like vs like operator : Oracle [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am searching for multiple phrases using SQL 'like' operator. Same results can be extracted using Regexp_like function in Oracle. Which one is better/efficient to use and why? My observation is that 'like' works much quicker than regEX.
I am running my queries against very large dataset with few million rows.
Here are both the versions of the query
Using like:
select
name
from
table
where
lower(result) like '%the condition is absent%'
or lower(result) like '%partial presence of disease%'
Using Regexp_like():
select
name
from
table
where
regexp_like(lower(result),'^.*(the condition is absent)|(partial presence of disease).*$')

How do I show ☺♦♦ characters in SQL Server? [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 7 years ago.
Improve this question
You can I display special Unicode characters in my result set on my SQL Server?
e.g. How can i display those characters ☺♦♦?
Well due to the fact that your question is very unspecific here are some solutions.
You need to specify a string as unicode string. This can be achieved by adding an N in front of the string. See example:
SELECT N'☺♦♦' as a, '☺♦♦' as b
Result:
a b
---- ----
☺♦♦ ???
If you want to store those symbols, you need a type as nvarchar or nchar.
Hopefully this helps you.

Fill with zero to complete a defined number in sql [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 7 years ago.
Improve this question
I need to complete cards numbers in sql. I have the prefix =11111 and the number of the card which is variable, therefore it could be '25' or '2130' but at the end I must have 14 numbers. So I need to fill spaces with zeros.
I've read about 'LPAD' but I don't understand very well this method.
You could use lpad, but if you're starting with a number you could use a 9-digit format model instead, and concatenate that onto your prefix:
select '11111' || to_char(25, 'FM000000000') from dual;
11111000000025
The FM format modifier stops Oracle adding a space for a potential +/- sign indicator.
SQL Fiddle demo
Use the ZEROFILL attribute.
But your database should only be responsible for saving data and not changing it before saving.
The best way would be to send the zerofilled data to the database server.

Is there a way to remove specific characters from SQL Server Column [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a database table that contains a column for pricing.
Its very old, so it was written before i understood datatypes. so we are using varchar for a money value.
Ive noticed some columns have $ in them, so what I'm wondering is... is there a way with SQL Server to perform an update of the table and remove any instances of non numeric characters or at the very least remove the $ from the string in the columns in one go ?
I hope this is possible.
Update tbl
SET price = replace(price, '$', '')
Here is the replace definition