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 2005 Forums
 Transact-SQL (2005)
 passing parameter

Author  Topic 

PatDeV
Posting Yak Master

197 Posts

Posted - 2009-01-04 : 00:17:18
declare @insertSQL nvarchar(max)
declare @day int
set @day = day(getdate())
set @insertSQL = 'insert into test.dbo.testnew2(name,date,day,test1,test2,test3) values (''@name'',''@Date'',@day,@test1,@test2,@test3)'

I am writing in sp. but it kept saying invalid colum. but the columns are same as structure!

What am missing??

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-04 : 03:36:46
whats the need of dynamic sql here? wont you require only this?

insert into test.dbo.testnew2(name,date,day,test1,test2,test3)
values (@name,@Date,@day,@test1,@test2,@test3)
Go to Top of Page

thiyagu_rind
Starting Member

46 Posts

Posted - 2009-01-23 : 00:21:53
hi,

Yeah, there is no need for the Dynamic Query and check the columns names are correctly matching with the table.

Regards
Thiyagarajan
www.sqlhunt.blogspot.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-23 : 00:58:47
quote:
Originally posted by thiyagu_rind

hi,

Yeah, there is no need for the Dynamic Query and check the columns names are correctly matching with the table.

Regards
Thiyagarajan
www.sqlhunt.blogspot.com


Echo after 19 days!
Go to Top of Page
   

- Advertisement -