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


SQL 2008 T-SQL


SQL 2008 T-SQL

Author
Message
bitbucket-25253
bitbucket-25253
SSCrazy Eights
SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)SSCrazy Eights (9.7K reputation)

Group: General Forum Members
Points: 9697 Visits: 25280
Comments posted to this topic are about the item SQL 2008 T-SQL

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Aluminum
Aluminum
SSC-Addicted
SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)

Group: General Forum Members
Points: 486 Visits: 339
Ummm.... I had an error when processing this sql. That is the option I picked before I answered and decided to check it after I was wrong.
kramaswamy
kramaswamy
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2052 Visits: 1812
did you try it in SSMS 2008? doens't work in 2005, those features are part of the 2008 version.
Aluminum
Aluminum
SSC-Addicted
SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)

Group: General Forum Members
Points: 486 Visits: 339
Did not. Thanks for the post.
Michael Poppers
Michael Poppers
SSC Eights!
SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)

Group: General Forum Members
Points: 919 Visits: 416
I thought @msg *= 3 would not work -- my bad :-).
kevin.l.williams
kevin.l.williams
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3493 Visits: 1323
I thought this wouldn't work because I assumed 2005 worked the same as 2008. I was surprised to see that I was wrong. I wanted to see it work in 2008 but when I ran it my server returned this error.

@i @Msg Date
----------- ----- --------
An error occurred while executing batch. Error message is: Invalid attempt to GetBytes on column 'Date'. The GetBytes function can only be used on columns of type Text, NText, or Image.

What does this mean?

-Kevin



Bhavesh-1094084
Bhavesh-1094084
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 110
DECLARE @i AS INT = 100,@msg AS VARCHAR(5)= '11',@Date AS DATE=GETDATE()



will generate error "Cannot assign a default value to a local variable."

Bhavesh
.NET and SQL Server Blog
kevin.l.williams
kevin.l.williams
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3493 Visits: 1323
bhavster27 (8/25/2009)
DECLARE @i AS INT = 100,@msg AS VARCHAR(5)= '11',@Date AS DATE=GETDATE()



will generate error "Cannot assign a default value to a local variable."


Not for SQL 2008



KevinC.
KevinC.
SSC Eights!
SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)SSC Eights! (811 reputation)

Group: General Forum Members
Points: 811 Visits: 504
Good question!
john.moreno
john.moreno
Mr or Mrs. 500
Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)

Group: General Forum Members
Points: 517 Visits: 1115
On my SQL 2008 server (using the Master database so no question of compatibility level) this fails with the previously mentioneed "GetBytes function" error.


use master
DECLARE @Date AS DATE=GETDATE()
SELECT @Date as '@Date'

An error occurred while executing batch. Error message is: Invalid attempt to GetBytes on column '@Date'. The GetBytes function can only be used on columns of type Text, NText, or Image.



If you explicitly cast the DATE to CHAR or VARCHAR then it works (also if you change the type of date to DATETIME). I'm not sure why this is so, as the conversion page says that there is an implicit conversion from Date to char and varchar AND no conversion possible to Text, NText or Image.

So, I got the right answer for the wrong reason, but it was graded wrong for an unknown reason. Sounds fair to me.
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