Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Simple Interview Question Rate Topic Display Mode Topic Options
Author
 Message
 Posted Wednesday, July 24, 2013 7:29 AM
 SSC Rookie Group: General Forum Members Last Login: Wednesday, November 13, 2013 7:23 AM Points: 46, Visits: 181
 select 5 & 17 What is the Output? Ans is :1 1)how it will return 1 ? 2)what is the use of this query? any one explain it pls..Thank & RegardsSaravanan.D
Post #1477050
 Posted Wednesday, July 24, 2013 7:36 AM
 SSChampion Group: General Forum Members Last Login: Today @ 1:39 PM Points: 12,667, Visits: 30,740
 its a binary AND operation.` 5 = 0000010117 = 00010001`the only column in BOTH values binary representation above is the first column, representing 2^0, so the value is 1.`16 = 0001000017 = 00010001`when AND-ing 16, and 16, the only shared column si the 2^4 column, which is 16. Lowell--There is no spoon, and there's no default ORDER BY in sql server either.Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1477057
 Posted Wednesday, July 24, 2013 8:26 AM
 SSC Rookie Group: General Forum Members Last Login: Thursday, November 07, 2013 1:58 PM Points: 28, Visits: 261
 Lowell (7/24/2013)its a binary AND operation.` 5 = 0000010117 = 00010001`the only column in BOTH values binary representation above is the first column, representing 2^0, so the value is 1.`16 = 0001000017 = 00010001`when AND-ing 16, and 16, the only shared column si the 2^4 column, which is 16.I just had PTSD flashbacks to assembly.
Post #1477090
 Posted Wednesday, July 24, 2013 8:38 AM
 SSChampion Group: General Forum Members Last Login: Today @ 1:28 PM Points: 11,644, Visits: 10,745
 I would have to say that is an absolutely horrid interview question. It is not testing your skills with sql server. I have seen the binary AND around the forums but I have never come across it in the real world (at least not in sql server). _______________________________________________________________Need help? Help us help you. Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.Need to split a string? Try Jeff Moden's splitter.Cross Tabs and Pivots, Part 1 – Converting Rows to Columns Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs Understanding and Using APPLY (Part 1)Understanding and Using APPLY (Part 2)
Post #1477100
 Posted Wednesday, July 24, 2013 8:50 AM
 SSCrazy Group: General Forum Members Last Login: 2 days ago @ 3:53 AM Points: 2,792, Visits: 4,872
 Sean Lange (7/24/2013)I would have to say that is an absolutely horrid interview question. It is not testing your skills with sql server. I have seen the binary AND around the forums but I have never come across it in the real world (at least not in sql server).It's called "Bitwise AND" :http://msdn.microsoft.com/en-us/library/ms174965.aspxI have used it few times... I'll try to find one thread on this forum where I've used it to help to achieve quite interesting requirements. _____________________________________________"The only true wisdom is in knowing you know nothing""O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"(So many miracle inventions provided by MS to us...)How to post your question to get the best and quick help
Post #1477110
 Posted Wednesday, July 24, 2013 9:03 AM
 SSChampion Group: General Forum Members Last Login: Today @ 1:28 PM Points: 11,644, Visits: 10,745
 Eugene Elutin (7/24/2013)Sean Lange (7/24/2013)I would have to say that is an absolutely horrid interview question. It is not testing your skills with sql server. I have seen the binary AND around the forums but I have never come across it in the real world (at least not in sql server).It's called "Bitwise AND" :http://msdn.microsoft.com/en-us/library/ms174965.aspxI have used it few times... I'll try to find one thread on this forum where I've used it to help to achieve quite interesting requirements.I knew it wasn't binary AND but couldn't think of the proper name for the life of me. If you can find that thread it would be interesting. I still say it is a poor interview question because it so rarely used. _______________________________________________________________Need help? Help us help you. Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.Need to split a string? Try Jeff Moden's splitter.Cross Tabs and Pivots, Part 1 – Converting Rows to Columns Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs Understanding and Using APPLY (Part 1)Understanding and Using APPLY (Part 2)
Post #1477117
 Posted Wednesday, July 24, 2013 9:13 AM
 SSCommitted Group: General Forum Members Last Login: Monday, March 03, 2014 4:15 AM Points: 1,694, Visits: 19,547
 You can use '&' for decoding @@OPTIONS`PRINT @@OPTIONSIF ( (8 & @@OPTIONS) = 8 ) PRINT 'ANSI_WARNINGS'IF ( (16 & @@OPTIONS) = 16 ) PRINT 'ANSI_PADDING'IF ( (32 & @@OPTIONS) = 32 ) PRINT 'ANSI_NULLS'IF ( (64 & @@OPTIONS) = 64 ) PRINT 'ARITHABORT'IF ( (256 & @@OPTIONS) = 256 ) PRINT 'QUOTED_IDENTIFIER'IF ( (512 & @@OPTIONS) = 512 ) PRINT 'NOCOUNT'` ____________________________________________________How to get the best help on a forumhttp://www.sqlservercentral.com/articles/Best+Practices/61537Never approach a goat from the front, a horse from the rear, or a fool from any direction.
Post #1477125
 Posted Wednesday, July 24, 2013 9:34 AM
 SSCommitted Group: General Forum Members Last Login: Monday, March 03, 2014 4:15 AM Points: 1,694, Visits: 19,547
 Here's a query using '&'http://www.sqlservercentral.com/Forums/FindPost1422007.aspx ____________________________________________________How to get the best help on a forumhttp://www.sqlservercentral.com/articles/Best+Practices/61537Never approach a goat from the front, a horse from the rear, or a fool from any direction.
Post #1477135
 Posted Wednesday, July 24, 2013 9:42 AM
 SSChampion Group: General Forum Members Last Login: Today @ 1:28 PM Points: 11,644, Visits: 10,745
 Mark-101232 (7/24/2013)Here's a query using '&'http://www.sqlservercentral.com/Forums/FindPost1422007.aspxI remember that thread. And I would say that yes it can be done but the end result is a static set of values. I would say that doing this in sql is rather pointless.Your example of parsing OPTIONS though is pretty cool. _______________________________________________________________Need help? Help us help you. Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.Need to split a string? Try Jeff Moden's splitter.Cross Tabs and Pivots, Part 1 – Converting Rows to Columns Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs Understanding and Using APPLY (Part 1)Understanding and Using APPLY (Part 2)
Post #1477138
 Posted Thursday, July 25, 2013 1:47 AM
 SSChampion Group: General Forum Members Last Login: Today @ 6:32 AM Points: 11,908, Visits: 8,843
 sarwaanmca (7/24/2013)select 5 & 17 What is the Output? Ans is :1 1)how it will return 1 ? 2)what is the use of this query? any one explain it pls..Thank & RegardsSaravanan.DMy answer to a question like this (if I wouldn't know the answer):"Can you show me a useful query for this?"Probably will knock their socks off How to post forum questions.Need an answer? No, you need a question.What’s the deal with Excel & SSIS?Member of LinkedIn. My blog at LessThanDot. MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1477370

 Permissions