Legend
Legend

Reputation: 117030

How can I set the maximum number of characters per column using sqlcmd?

While using SQL Server Management Studio, I generally do:

Query->Query Options->Advanced->SET NOCOUNT
Query->Query Options->Text->Enter 8000 in the lower right box

Can someone please tell me if there is anyway I could do this using sqlcmd?

Upvotes: 0

Views: 1756

Answers (2)

gbn
gbn

Reputation: 432702

You have these switches for sqlcmd that affect width etc

  • -w
  • -Y
  • -y

Upvotes: 1

Jandrejc
Jandrejc

Reputation: 499

I don't know if this is exactly what you are trying to do, but to set data type in the column for example to varchar with maximum length 30:

sqlcmd -E -d dbname -Q "ALTER TABLE table_name
                          ALTER COLUMN column_name varchar(30) NOT NULL"

For database named 'dbname' on your local machine.

Upvotes: 1

Related Questions