Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare string size

Status
Not open for further replies.

knela

Programmer
Jan 26, 2007
13
BR
Hello! How can I compare a table field size with a string?
 
You can get the table's field size by querying against the information_Schema.Columns view.

select * from Information_Schema.Columns

Or....
Code:
Declare @Size Int

Select @Size = Character_Maximum_Length
From   Information_Schema.Columns
Where  Table_Name = 'YourTableName'
       And Column_Name = 'YourColumnName'

If @Size >= Len(@YourString)
  Begin
    Select 'String is ok'
  End
Else
  Begin
    Select 'String is too long'
  End


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top