SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


T-SQL


T-SQL

Author
Message
malleswarareddy_m
malleswarareddy_m
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2713 Visits: 1189
greated question

Malleswarareddy
I.T.Analyst
MCITP(70-451)
Danny Ocean
Danny Ocean
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2200 Visits: 1549
Hi,

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

Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com
Peter E. Kierstead
Peter E. Kierstead
SSC Eights!
SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)SSC Eights! (846 reputation)

Group: General Forum Members
Points: 846 Visits: 453
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.
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25477 Visits: 12494
Really good question. Thanks.

Tom

irshadmohideen
irshadmohideen
Valued Member
Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)Valued Member (69 reputation)

Group: General Forum Members
Points: 69 Visits: 110
Excellent question. Good point emphasized when inserting with multiple value segments with single insert statement.
anders-731262
anders-731262
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1067 Visits: 362
Interesting, Thanks.
mferanda
mferanda
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 106
Nice post! Thanks!
Reji PR
Reji PR
SSC Journeyman
SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)SSC Journeyman (91 reputation)

Group: General Forum Members
Points: 91 Visits: 76
Nice question. got a good knowledge. thanks:-)

Thanks.

Reji PR,
Bangalore
:-D
Christian Buettner-167247
Christian Buettner-167247
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5201 Visits: 3889
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search