Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Intresting Question need answer ASAP Expand / Collapse
Author
Message
Posted Thursday, September 20, 2012 9:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, June 14, 2013 11:35 AM
Points: 24, Visits: 299
Write the shortest code that produces results as 1 without using any numbers in the select statement. using sql
Post #1362082
Posted Thursday, September 20, 2012 9:34 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, June 14, 2013 11:35 AM
Points: 24, Visits: 299
One more

SELECT CAST(634 AS VARCHAR(2))

why it display * in result
Post #1362083
Posted Thursday, September 20, 2012 9:36 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 6:23 AM
Points: 606, Visits: 2,210
PRINT 1

Doesn't use a SELECT statement

Homework?

Andy


==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
Post #1362087
Posted Thursday, September 20, 2012 9:38 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 6:22 AM
Points: 38,077, Visits: 30,372
SELECT LEN('a')


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1362090
Posted Thursday, September 20, 2012 9:40 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 10:15 AM
Points: 463, Visits: 2,714
GilaMonster (9/20/2012)
SELECT LEN('a')


ha, thats what i came up with
Post #1362092
Posted Thursday, September 20, 2012 9:40 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 6:23 AM
Points: 606, Visits: 2,210

One more

SELECT CAST(634 AS VARCHAR(2))

why it display * in result


Someone else also asked this
http://www.sqlservercentral.com/Forums/Topic1361763-149-1.aspx


==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
Post #1362093
Posted Thursday, September 20, 2012 9:40 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832, Visits: 27,855
vax09 (9/20/2012)
One more

SELECT CAST(634 AS VARCHAR(2))

why it display * in result


Overflow, you are trying to convert the number 634 to a string but only giving the string 2 characters of space where 3 are needed.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1362095
Posted Thursday, September 20, 2012 9:41 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, June 14, 2013 11:35 AM
Points: 24, Visits: 299
For this query

SELECT CAST(634 AS VARCHAR(2))

why it display * in result
Post #1362096
Posted Thursday, September 20, 2012 10:27 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 6:22 AM
Points: 38,077, Visits: 30,372
Andy Hyslop (9/20/2012)

Someone else also asked this
http://www.sqlservercentral.com/Forums/Topic1361763-149-1.aspx



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1362138
Posted Thursday, September 20, 2012 11:00 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 1:45 PM
Points: 15,442, Visits: 9,572
vax09 (9/20/2012)
For this query

SELECT CAST(634 AS VARCHAR(2))

why it display * in result


String truncation.


- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1362166
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse