Solved

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

Posted on 2015-01-04
2
111 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now