How to enter long SQL text data with Visual Studio?

The Server Explorer built into Visual Studio is a good way to connect to your database, view existing data, and edit data. Very useful for entering sample data into a database for testing and development purposes.

However, what if you have a "text" column and want to enter a long text field? For example, I have a text column where I want to store a multi-line XML value. I would like to be able to do multi-line editing inside the table data viewer.

I can't figure out how to do this? Does anyone know if this can be done and if so how?

+1


a source to share


2 answers


I do not think that's possible. Management Studio displays multi-line text as one line.



+1


a source


I don't think the editor supports multi-line input or editing. However, you can enter multiple line data by creating a simple INSERT statement. For instance:

CREATE TABLE TableA (
  id INT IDENTITY PRIMARY KEY,
  data VARCHAR(MAX)
)

INSERT INTO TableA (data) VALUES
('row 1
row 2
row 3')

      



Then just select the entire INSERT statement and all the data and press F5 to execute it.

Also, FWIW, the TEXT data type is deprecated; VARCHAR (MAX) is a replacement (better for many reasons).

0


a source







All Articles