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: Thursday, December 1, 2016 8:10 AM Points: 46, Visits: 192
 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 @ 4:40 AM Points: 14,556, Visits: 38,434
 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--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1477057
 Posted Wednesday, July 24, 2013 8:26 AM
 SSC Rookie Group: General Forum Members Last Login: Tuesday, December 16, 2014 3:18 PM Points: 30, Visits: 280
 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
 SSCoach Group: General Forum Members Last Login: Tuesday, December 6, 2016 8:08 PM Points: 16,145, Visits: 16,850
 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: Tuesday, December 6, 2016 8:21 AM Points: 2,934, Visits: 5,478
 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
 SSCoach Group: General Forum Members Last Login: Tuesday, December 6, 2016 8:08 PM Points: 16,145, Visits: 16,850
 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
 SSCrazy Group: General Forum Members Last Login: Today @ 4:50 AM Points: 2,015, Visits: 22,630
 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'` ____________________________________________________Deja View - The strange feeling that somewhere, sometime you've optimised this query beforeHow to get the best help on a forumhttp://www.sqlservercentral.com/articles/Best+Practices/61537
Post #1477125
 Posted Wednesday, July 24, 2013 9:34 AM
 SSCrazy Group: General Forum Members Last Login: Today @ 4:50 AM Points: 2,015, Visits: 22,630
 Here's a query using '&'http://www.sqlservercentral.com/Forums/FindPost1422007.aspx ____________________________________________________Deja View - The strange feeling that somewhere, sometime you've optimised this query beforeHow to get the best help on a forumhttp://www.sqlservercentral.com/articles/Best+Practices/61537
Post #1477135
 Posted Wednesday, July 24, 2013 9:42 AM
 SSCoach Group: General Forum Members Last Login: Tuesday, December 6, 2016 8:08 PM Points: 16,145, Visits: 16,850
 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
 SSCoach Group: General Forum Members Last Login: Today @ 1:35 AM Points: 15,509, Visits: 13,170
 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 SQLKover. MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1477370

 Permissions