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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 inserting a sql query into a column

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-29 : 12:12:35
Annonymous writes "Hi,
How can i insert a sql query in a column.
For e.g.

strsql="select * from ind_cust where username='sachin' and date='12/2/200'

insert into <table-name> values(strsql)

The code is written in asp.

Please reply asap
Tahnkjs in advacne"

skillile
Posting Yak Master

208 Posts

Posted - 2001-12-29 : 14:02:30
--should use a SPROC
--and I don't think ?'s on ASP are so
--popular here but


strsql="insert into table (field1, field2) values('" & variable & "','" & variable2 & "')""

--something like that
--play with it

slow down to move faster...
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2001-12-29 : 14:27:47
You'll need to convert your single quotes (apostraphe's) into pairs of quotes. Please see this article: http://www.sqlteam.com/item.asp?ItemID=293. Once that is handled you should be able to insert the string into a table just like any string.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-30 : 03:05:08
Did you want to insert the TEXT of the query, or the RESULTS of the query? If you want the TEXT, then you've got your answers above, but if you want the RESULTS, then what you really want is to lookup the INSERT...SELECT... statement in Books Online. It would look something like this...

INSERT INTO Table1 (FirstName, LastName, Salary)
SELECT Fname, LName, Salary FROM Table2

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page
   

- Advertisement -