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
 how to insert rows to the talbles

Author  Topic 

CoolMoon2011
Starting Member

31 Posts

Posted - 2012-01-12 : 12:16:41
how to insert one extral row into my tables

I have the table with two columns,

like this:

Runtype groupfield

I want to insert one row,

runtype= Good , groupfiled= G + '_' + case when [iss-year] < 2007 then ''O'' else ''N'' end + ''_''
+ cast(company as varchar(2)),


finally the table looks like this

Runtype groupfield

Good G + '_' + case when [iss-year] < 2007 then ''O'' else ''N'' end + ''_''
+ cast(company as varchar(2)),

I will use the groupfield for a @string later

like Select @string1='groupdfield'







visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-12 : 12:26:10
[code]
insert into table (Runtype, groupfield)
values('Good','G + ''_'' + case when [iss-year] < 2007 then ''O'' else ''N'' end + ''_''
+ cast(company as varchar(2)),')

[/code]

i dont think its a good approach to store query part like this. Can i ask reason for this?


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-12 : 12:55:52
why should you take it as value at run time and then form query and execute? where do you get these code snippets from?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -