Hi,
I am currently inserting a record using:
insert into TABLE(FIELD1,FIELD2) values ('%s',%d)
But, the problem I have is that the table I am connecting to can either have
46 fields or 47 fields depending on its version. Is there a command that
would allow me to use an existing record as a template and only specified
the fields I want to change and then insert the new record?
Something like:
insert into TABLE(FIELD1) value ('%s') using template record where
FIELD1='9999999' ?
Thanks,
SA DevYour question is not clear
Give some sample data with expected result
Madhivanan|||Select SubQuery.* Into
NameOfYourNewTable
From
(
Select *,'Value' as NewColumnName From yourOldtable
) SubQuery
' That what you mean '
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"SA Development" <nospam38925@.forme.com> schrieb im Newsbeitrag
news:ILSdnRsNE_DG4jTfRVn-2A@.valortelecom.com...
> Hi,
> I am currently inserting a record using:
> insert into TABLE(FIELD1,FIELD2) values ('%s',%d)
> But, the problem I have is that the table I am connecting to can either
> have
> 46 fields or 47 fields depending on its version. Is there a command that
> would allow me to use an existing record as a template and only specified
> the fields I want to change and then insert the new record?
> Something like:
> insert into TABLE(FIELD1) value ('%s') using template record where
> FIELD1='9999999' ?
> Thanks,
> SA Dev
>
>|||Perhaps you could add a default for the additional column where it
exists and then you might not have to reference that column at all.
Alternatively, use SPs to insulate your application from different
schema versions. One of the big benefits of using SPs for data access
code is that they provide a single point of entry that can be made
backwards-compatible in later versions.
Failing that you may have to resort to Dynamic SQL. Make sure you read
up on all the implications first:
http://www.sommarskog.se/dynamic_sql.html
David Portas
SQL Server MVP
--
Showing posts with label field1. Show all posts
Showing posts with label field1. Show all posts
Subscribe to:
Posts (Atom)