|
|
От: |
sadomovalex
|
http://sadomovalex.blogspot.com |
| Дата: | 30.06.06 16:50 | ||
| Оценка: | |||
и далее:To create a text pointer, execute an INSERT or UPDATE statement with data that is not NULL for the text, ntext, or image column
Соответственно возникает вопрос: что использовать в качестве этого ненулевого значения при insert-е в столбец типа image? В случае text/ntext можно использовать к примеру пустую строку, а с image непонятноInserting a null value into a text or image column does not create a valid text pointer, nor does it preallocate an 8-KB text page
CREATE TABLE [dbo].[attachment] (
[AttachmentId] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [nvarchar] (255) NOT NULL ,
[Content] [image] NOT NULL ,
[Type] [nvarchar] (10) NOT NULL ,
[MailId] [int] NOT NULL
) ON [PRIMARY]
...
/**************************************************************************************/
/**/
CREATE PROCEDURE up_InsertAttachment
@name nvarchar (255),
@content image,
@type nvarchar(10),
@mailId int
AS
-- чтобы это сделать надо добавить DEFAULT значение для поля Content. Какое???
INSERT INTO attachment ([Name], Type, MailId)
VALUES (@name, @type, @mailId)
DECLARE @attachmentId int
SET @attachmentId = SCOPE_IDENTITY()
DECLARE DECLARE @ptr binary(16)
SELECT @ptr = TEXTPTR(Content)
FROM attachment
WHERE AttachmentId = @attachmentId
WRITETEXT attachment.Content @ptr @content
GO