Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert from different sources

Author  Topic 

ghazanfar
Starting Member

3 Posts

Posted - 2007-02-09 : 13:56:32
Hi everyone,

Can I do an insert with one column value being specified and the others being retrieved? Basically, I have to take an input from the user, join that input with the result of a select (based on that input) and post that to a table
I don’t suppose we can do something like

INSERT destTable(col1, col2, col3….)
Values (col1_value, (Select (…..)))

What do y'all think? Any input/suggestion is appreciated! :)

Thanks,

Gijoo

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-09 : 14:00:21
I'm assuming the "input" from the user is a local variable

INSERT Table(collist)
SELECT @UserInput, Col1, col2, ect
FROM TABLE
WHERE whatever


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

ghazanfar
Starting Member

3 Posts

Posted - 2007-02-09 : 14:13:12
That was fast! Thanks Bret =)

Gijoo
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-09 : 14:43:42
What? You think we're play'n here?

4 Minutes....I must be getting old



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

ghazanfar
Starting Member

3 Posts

Posted - 2007-02-09 : 15:04:21
hahah dont be too hard on yourself, anyone wanting help can wait 4 minutes =D
Go to Top of Page
   

- Advertisement -