Showing posts with label template. Show all posts
Showing posts with label template. Show all posts

Monday, March 19, 2012

2ND POST: Is there a way to insert a record using another as a template?

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
--

Thursday, February 16, 2012

2005 install - Can you specify a directory for the data and one for the logs?

Hi,
I am setting up a template.ini file that I am going to use for some
unattended installs of SQL Server 2005. I believe using the
'INSTALLSQLDATADIR' I can get the system databases setup with their
data files and log in the directory I specify. Is there a way to
specify a location for the logs and a location for the data files?I don't think so. There is really not much a need for that either.
Linchi
"Paul T." wrote:
> Hi,
> I am setting up a template.ini file that I am going to use for some
> unattended installs of SQL Server 2005. I believe using the
> 'INSTALLSQLDATADIR' I can get the system databases setup with their
> data files and log in the directory I specify. Is there a way to
> specify a location for the logs and a location for the data files?
>|||Most people split their user databases so that the log is on one
physical drive and the logs are on another so that I/O is distributed
and so that if they do not lose both the log and data file if a drive
goes, why not do that with the system databases too?|||Paul T. wrote:
> Most people split their user databases so that the log is on one
> physical drive and the logs are on another so that I/O is distributed
> and so that if they do not lose both the log and data file if a drive
> goes, why not do that with the system databases too?
>
Your system tables should have very little I/O against them, and good
backups will protect you from losing them...
Tracy McKibben
MCDBA
http://www.realsqlguy.com