Solved

Can we insert one of the columns of a table with select statement with a function?

Posted on 2015-01-04
2
114 Views
Last Modified: 2015-01-04
My requirement is I have an Emp table with 3 columns as shown below.I want to insert some test data.
CREATE TABLE dbo.Emp (
            EmployeeNumber                  Varchar(10)            NULL,
            LastName                        Varchar(50)            NULL,
            Hobby                              Varchar(max)      NULL
                                                )

I am inserting like this giving me an error.
INSERT INTO dbo.EmployeeHobby
      Values('101','Pam','Tom', SELECT REPLICATE('TAP',300))

Since the last coulmn is VARCHAR(MAX),i need to have some test data in the table.
0
Comment
Question by:Latha M
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40530519
Try dropping the values and using a select instead

INSERT INTO dbo.EmployeeHobby
      Select '101','Pam','Tom', REPLICATE('TAP',300)
0
 

Author Closing Comment

by:Latha M
ID: 40530523
Thank you very much
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question