use datalength function in mssqlserver

DECLARE @TestVariable AS VARCHAR
DECLARE @NextTestVariable AS CHAR
SET @TestVariable = ‘abc’
SET @NextTestVariable = ‘abc’
SELECT DATALENGTH(@TestVariable), DATALENGTH(@NextTestVariable)

Correct answer:
1,1
Explanation:
When length is not specified in a variable declaration statement in VARCHAR/CHAR, the default length is 1.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s