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.
| Author |
Topic |
|
RAVSKINS
Starting Member
21 Posts |
Posted - 2009-05-21 : 15:31:55
|
| Quick breakdown of what I'm trying to accomplish:I have a column in a table on my database that should be a static/fixed value - a 36 character uniqueidentifier. This column should never contain any other value than this uniqueidentifier. However, at some unknown point, this field is occasionally NULLED out, and users are unable to process their orders as needed. When this happens, I have to manually enter the uniqueidentifier back into that particular table entry. I'm searching for the bit of code that's causing the table various entries to NULL out, but in the meantime (as a band-aid) I want to set up a stored procedure to run every 15-20 minutes and set any NULLS back to this static uniqueidentifier. This is the stored procedure that I've tried to create with no success:CREATE PROCEDURE [Owner].[Procedure_Name] ASUPDATE TABLE [Database].[Owner].[Tablename].ColumnNameWHERE ColumnName IS NULLSET [Database].[Owner].[Tablename].ColumnName = 'blah-blah-blah'GOAny help would be GREATLY appreciated. |
|
|
mualsh
Starting Member
8 Posts |
Posted - 2009-05-21 : 15:45:33
|
| Here is the update query that you need inside the procedure:Update [Database].[Owner].[Tablename] Set ColumnName = 36 -- or whatever.... Where ColumnName IS NULL |
 |
|
|
RAVSKINS
Starting Member
21 Posts |
Posted - 2009-05-21 : 15:51:08
|
quote: Originally posted by mualsh Here is the update query that you need inside the procedure:Update [Database].[Owner].[Tablename] Set ColumnName = 36 -- or whatever.... Where ColumnName IS NULL
Thanks - I'll try it out. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-22 : 04:46:25
|
| if you want this unique identifier to take value automatically on each insert why not add a default constraint on it based on NEWID() function to generate value each time? |
 |
|
|
|
|
|