hiiii how can I use 2 different select statement to insert 2 different values in same insert statement ????

Recommended Answers

All 5 Replies

IF OBJECT_ID('TestTable', 'U') IS NOT NULL DROP TABLE TestTable
Create Table TestTable
(
  Col1 varchar(30),
  Col2 varchar(30)
)
Insert Into TestTable (Col1, Col2) Values ('a', 'b')
GO

IF OBJECT_ID('tempdb..#Temp', 'U') IS NOT NULL DROP TABLE #Temp
Create Table #Temp
(
  Col1 varchar(30),
  Col2 varchar(30)
)

GO 

--Now we have our test data setup

Insert Into #Temp (Col1, Col2)
Select
(Select Top 1 Col1 From TestTable) As Col1,
(Select Top 1 Col2 From TestTable) As Col2

Select *
From #Temp

I got unspecified error
this is my code:

("insert into Results (cnt, a_q1) select(select count (*) from Answers) as cnt, (select count(*) from Answers where answer_q1='ضعيف')as a_q1")

solved :) I put from at the end

Good deal

Please mark these threads as solved as you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.