Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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

743 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

11 Experts available now in Live!

Get 1:1 Help Now