Christmas is just near and happy holidays to all of you. Today is Christmas eve and I decided to share something very simple but interesting with you. Recently some one reading my SQL Server Interview Questions and Answers book asked me following question.
Instead of puzzle, or difficult interview question, I was asked following riddle in my interview. I could not answer it, do you have any idea.
Riddle: Create a table with two columns but you are allowed to specify datatypes only once. Additionally, write a mechanism that your data is copied from first column to second column without using any update statement. Also the column name should not contain any alphanumeric character.
How do I do this?”
For a moment I was confused too. As the requirement were very interesting, coping data without using update statement, no use of alphanumeric statement etc.
Finally I came up with following small and quick script.
CREATE TABLE MyTabs ([!] INT, [!!] AS [!]);
INSERT INTO MyTabs VALUES (1);
SELECT * FROM MyTabs;
If you are free, can you come up with further optimize script?
Reference: Pinal Dave (https://blog.sqlauthority.com)
its very much interesting!!
very interesting pinal, thanks for your sharing
It’z Awesome..Thanks For sharing with us..