?
Solved

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

Posted on 2015-01-04
2
Medium Priority
?
122 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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

765 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