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

T-SQL Expand / Collapse
Author
Message
Posted Wednesday, March 23, 2011 8:12 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 11:09 PM
Points: 1,940, Visits: 1,173
greated question

Malleswarareddy
I.T.Analyst
MCITP(70-451)
Post #1082706
Posted Thursday, March 24, 2011 7:03 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, February 6, 2014 4:15 AM
Points: 1,242, Visits: 1,546
Hi,

It's really very good question. thanks for sharing.




Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com

Post #1083254
Posted Thursday, March 24, 2011 1:00 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 9:36 AM
Points: 190, Visits: 442
Note:
insert into #test values (2,'D'),('','E') is equal to insert into #test select 2,'D' union select '','E'

Actually, its like:
insert into #test values (2,'D'),('','E') is equal to insert into #test select 2,'D' union all select '','E'




PeteK
I have CDO. It's like OCD but all the letters are in alphabetical order... as they should be.
Post #1083546
Posted Saturday, March 26, 2011 9:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:45 AM
Points: 7,860, Visits: 9,606
Really good question. Thanks.

Tom
Post #1084449
Posted Sunday, March 27, 2011 9:46 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, July 22, 2013 6:33 AM
Points: 57, Visits: 110
Excellent question. Good point emphasized when inserting with multiple value segments with single insert statement.
Post #1084679
Posted Monday, March 28, 2011 1:21 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, October 20, 2014 6:19 AM
Points: 985, Visits: 351
Interesting, Thanks.
Post #1084738
Posted Monday, March 28, 2011 11:13 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, July 15, 2012 11:51 PM
Points: 65, Visits: 103
Nice post! Thanks!
Post #1085298
Posted Saturday, April 2, 2011 1:28 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 3, 2014 11:44 PM
Points: 39, Visits: 75
Nice question. got a good knowledge. thanks

Thanks.

Reji PR,
Bangalore

Post #1087791
Posted Monday, August 8, 2011 1:03 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:56 AM
Points: 2,842, Visits: 3,876
pksutha (3/23/2011)
Hi Gopi,

select * into TestTable from
(
select CAST(1 as smallint) as C1, CAST(6 as smallint) as C2
union
select CAST(2 as tinyint),CAST(6 as int)
union
select CAST(3 as bigint),CAST(6 as smallint)
union
select CAST(4 as int),CAST(6 as tinyint)
) T

Note: Practically i want to see the difference... will u give example for that..


Hi pksutha,

try this query to see the resulting data type:
SELECT RowID
,Col
,SQL_VARIANT_PROPERTY(Col,'BaseType') BaseType
,SQL_VARIANT_PROPERTY(Col,'Precision') Precision
,SQL_VARIANT_PROPERTY(Col,'Scale') Scale
,SQL_VARIANT_PROPERTY(Col,'TotalBytes') TotalBytes
,SQL_VARIANT_PROPERTY(Col,'Collation') Collation
,SQL_VARIANT_PROPERTY(Col,'MaxLength') MaxLength
FROM (
SELECT 1 AS RowID, CAST(1 AS int) Col
UNION ALL SELECT 2 AS RowID, CAST('2' AS char) Col
)SubQ

And play a little with the datatypes & order of data types in the CASTs to see what the resulting data type will be.


Best Regards,
Chris Büttner
Post #1155846
« Prev Topic | Next Topic »

Add to briefcase «««12345

Permissions Expand / Collapse