Solved

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

Posted on 2015-01-04
2
120 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

707 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