Hi
If you specify the column list then you insert values into those columns.
Missing columns will be set to NULL (if it is allowed) or a default value.
To update existing data use the UPDATE statement, you will only change the
values for columns specified in the SET clause. More information on the
INSERT and UPDATE statements can be found in Books Online.
Using stored procedure may help to remove any issues with different versions
as you will ship the correct procedure with the changes to the schema.
You can look at the INFORMATION_SCHEMA.columns view to find out what columns
a table has, although a different approach would be to only provide a
solution for the latest version and check they are on that version otherwise
force an upgrade.
John
"SA Development" wrote:
> 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 ha
ve
> 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
>
>Thanks for the good ideas everyone, sorry my first post wasn't entirely
clear.
Lets say I have a table like this:
field1(key) field2 field3 field4 field5
9999 a b c d
What I was hoping to do is add a new record (field1=123 for example), but
use the 9999 as a template record so that its field values are inserted into
my new record EXCEPT for any that I override.
It sounds like the update command will let me update just the fields I want,
is there a way to tell SQL to copy record 9999 to record 123 and use all the
field values in record 9999 ?
Thanks,
Alan|||Hi David,
> INSERT INTO YourTable (col1, col2, col3, col4, col5)
> SELECT 123, col2, col3, col4, col5
> FROM YourTable
> WHERE col1 = 9999
Thank you -- that is exactly what I needed!
Thanks to everyone else who posted as well.
Have a great day,
Alan
Showing posts with label specify. Show all posts
Showing posts with label specify. Show all posts
Monday, March 19, 2012
Tuesday, March 6, 2012
2005 Workgroup - 'Create failed for jobstep' error creating backup
Hello,
I am running into an error when creating maintenence jobs in SQL Management
Studio. I can create the new jobs and specify all the options, but when I
attempt to save the job I receive the following error:
"Create failed for JobStep 'jobname'" or
"Create failed for Job 'jobname"
Here's my setup:
SQL 2005 Workgroup Edition SP1
Windows SBS 2003 SP1
I saw a Microsoft KB article, and several forums which confirm this, stating
that SQL Server 2005 Integration Services (SSIS) need to be installed for
maintenance jobs to be created successfully. However, and here's the catch
22, SSIS is not an available installation options in SQL Server 2005
Workgroup edition. So... how do I go about resolving this issue when the
recommended fix is not available for my version of SQL 2005?
Thanks for any help!Sorry, meant to include this in the original post... here is the MS KB
article I was referring to:
http://support.microsoft.com/kb/909036
"Epsil0n" wrote:
> Hello,
> I am running into an error when creating maintenence jobs in SQL Management
> Studio. I can create the new jobs and specify all the options, but when I
> attempt to save the job I receive the following error:
> "Create failed for JobStep 'jobname'" or
> "Create failed for Job 'jobname"
> Here's my setup:
> SQL 2005 Workgroup Edition SP1
> Windows SBS 2003 SP1
> I saw a Microsoft KB article, and several forums which confirm this, stating
> that SQL Server 2005 Integration Services (SSIS) need to be installed for
> maintenance jobs to be created successfully. However, and here's the catch
> 22, SSIS is not an available installation options in SQL Server 2005
> Workgroup edition. So... how do I go about resolving this issue when the
> recommended fix is not available for my version of SQL 2005?
> Thanks for any help!
I am running into an error when creating maintenence jobs in SQL Management
Studio. I can create the new jobs and specify all the options, but when I
attempt to save the job I receive the following error:
"Create failed for JobStep 'jobname'" or
"Create failed for Job 'jobname"
Here's my setup:
SQL 2005 Workgroup Edition SP1
Windows SBS 2003 SP1
I saw a Microsoft KB article, and several forums which confirm this, stating
that SQL Server 2005 Integration Services (SSIS) need to be installed for
maintenance jobs to be created successfully. However, and here's the catch
22, SSIS is not an available installation options in SQL Server 2005
Workgroup edition. So... how do I go about resolving this issue when the
recommended fix is not available for my version of SQL 2005?
Thanks for any help!Sorry, meant to include this in the original post... here is the MS KB
article I was referring to:
http://support.microsoft.com/kb/909036
"Epsil0n" wrote:
> Hello,
> I am running into an error when creating maintenence jobs in SQL Management
> Studio. I can create the new jobs and specify all the options, but when I
> attempt to save the job I receive the following error:
> "Create failed for JobStep 'jobname'" or
> "Create failed for Job 'jobname"
> Here's my setup:
> SQL 2005 Workgroup Edition SP1
> Windows SBS 2003 SP1
> I saw a Microsoft KB article, and several forums which confirm this, stating
> that SQL Server 2005 Integration Services (SSIS) need to be installed for
> maintenance jobs to be created successfully. However, and here's the catch
> 22, SSIS is not an available installation options in SQL Server 2005
> Workgroup edition. So... how do I go about resolving this issue when the
> recommended fix is not available for my version of SQL 2005?
> Thanks for any help!
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
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
Subscribe to:
Posts (Atom)