how to use uniqueidentifier in sql server 2008

Posted by Shanky11 under Sql Server on 2/27/2013 | Points: 10 | Views : 1481 | Status : [Member] | Replies : 9
i have create a table Sending Master
column name
messageuid uniqueidentifier
send date
send message
send name
now i m inserting value it showing error
i m not inserting value in message bcauz its is self increment
how can i overcome this problem




Responses

Posted by: Santhi on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Set Identity and Autoincrement to true for that particular column.



Thanks & Regards,
Santhi .V

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
santhi
these options is not there i m using sql 2008r2
i have created table by wizard not by writting query


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 2/27/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Do you want to set Auto Insert value on "messageuid" column ?

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
yes i want this

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 2/27/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Check It Out!
CREATE TABLE Sending

(
messageuid UNIQUEIDENTIFIER DEFAULT NEWID(),
senddate DATETIME,
sendmessage VARCHAR(MAX),
sendname VARCHAR(100)
)
GO

INSERT Sending(senddate,sendmessage,sendname) VALUES(GETDATE(),'Welcome to .NetFunda(C#)','Sheo')
INSERT Sending(senddate,sendmessage,sendname) VALUES(GETDATE(),'Welcome to .NetFunda(ASP.Net)','Vuyiswa')
INSERT Sending(senddate,sendmessage,sendname) VALUES(GETDATE(),'Welcome to .NetFunda(SQL Server)','Pandian')
GO

SELECT * FROM Sending
GO


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
Pandians
I m Creating this by right clicking database create tables
then how can i overcome this pblm???

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 2/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Shanky,

To auto increment Uniqueidentifier in design mode you need to set default value as newid()

Check the screenshot i am attaching.
 Download source file

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
hello RAJ
Now its executing but not showng any result

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 2/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello shanky,

I did not get you,what result are you expecting to be pulled out can you paste a sample query for the same.

For your table use this

insert into tableSample(send,sendmessage,sendname) values(getdate(),'Hello world','Raj')

please check its working for me if not please upload the screenshot for the result i will check

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response