Showing posts with label convert. Show all posts
Showing posts with label convert. Show all posts

Friday, February 24, 2012

Data Type timestamp

Hi,

I am a bit confused...

is the data type in sql express similar to DateTime? in other words can i convert this timestamp to DateTime or can i use this data type instead of the data type DateTime?

regards,

rnv

Even they store both 8 bytes, they are not the same, read more for this in the BOL.

timestamp

timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.

Remarks

The Transact-SQL timestamp data type is not the same as the timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL datetime data type.

http://msdn.microsoft.com/library/en-us/tsqlref/ts_ta-tz_6fn4.asp

If you want to use something like rowversioning, use ROWVERSION not datetime, as datetime has only the limitation to a precision of 3ms.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

thanks a lot.

|||Could you please mark the post as solved then, thanks.

Jens.

Sunday, February 19, 2012

Data type mismatch in criteria expression.

Hi,

I am santosh sending this mail regards database errorin vc++ 6.0 application . actually I am trying to convert old MS SQL server database to MS Access so what are the changes should I do in vc++ source code so it can work fine with MS Access. I am trying but it giving error on this statement as follows :-

strSQLString.MakeUpper();

ReturnCode = SQLExecDirect(m_hstmt,(UCHAR*)((LPCTSTR)strSQLString),SQL_NTS);

if (ReturnCode)

{

CDBException* pDBEx = new CDBException();

pDBEx->BuildErrorString(m_pDatabase,m_hstmt);

throw ( pDBEx);

return 0;

}

And this is sql statement witch is storing data in data type ofCStringstrSQLString;and the statement is as follows:-

strSQLString.Format("SELECT TOP %d MESSAGEID, MOBILENUMBER,MESSAGETEXT, SENDERID, RECDDATETIME, SENDDATETIME, SUBSCUSERID, SUBSCID, MESSAGESTATUS, RETURNCODE , PRIORITYLEVEL, VALIDITYDATETIME, MCL,CONFIRMREQD,DATAENCODING FROM SMSMESSAGES WHERE MESSAGESTATUS = 0", nRowsToFetch );

so I getting error likeby this in Debug mode throw (pDBEx);

Data type mismatch in criteria expression.

State:22005,Native:-3030,Origin:[Microsoft][ODBC Microsoft Access Driver]

And I am connecting throw database by DSN .

Please tell me the way for this is possible or not I am waiting for response .

Best regards,

S. Santosh Naidu

Is SMSMESSAGES.MESSAGESTATUS a varchar? If so, you'd want to rewrite your where clause to WHERE MESSAGESTATUS = '0' or similar. Send along your DDL for the table if this isn't the problem.

Hope this helps,
Josh Lindenmuth

Friday, February 17, 2012

Data Type Convertion Error

Hello,
I need to convert one character field to datetime and after make the
differenc between two fields.
The problem is that if in the output result appears one value that is
biggest then 23:59:59 hours its shown the
following error:
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
Example:
select convert(datetime, field, 108) from table_name
or
select convert (datetime, '24:00:00', 108) from table_name
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
I need to use all the results and know the difference between them in hour
or minutes.
Example:
select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
field_B, 108))
from table_name
Can you help me?
Thanks and best regards
Hi
24:00:00 is not a valid time. In effect, it is 00:00:00.000 the next day.
00:00:00.000 to 23:59:59.999 is
You need to fix your data to a ISO valid date value.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CD38A959-9022-4BA9-80B6-1AFCDE0AD8FB@.microsoft.com...
> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards
|||try...
select datediff(mi,
dateadd(ss,cast(substring(field1,1,2) as
int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,2)
as int),cast(0 as datetime)),
dateadd(ss,cast(substring(field2,1,2) as
int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,2)
as int),cast(0 as datetime))
)
-- example
select datediff(mi,
dateadd(ss,cast(substring('34:15:10',1,2) as
int)*60*60+cast(substring('34:15:10',4,2) as int)*60+
cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
dateadd(ss,cast(substring('24:18:10',1,2) as
int)*60*60+cast(substring('24:18:10',4,2) as int)*60+
cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
)
"CC&JM" wrote:

> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards
|||Thanks everybody.
Best regards
"Aleksandar Grbic" wrote:
[vbcol=seagreen]
> try...
> select datediff(mi,
> dateadd(ss,cast(substring(field1,1,2) as
> int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,2)
> as int),cast(0 as datetime)),
> dateadd(ss,cast(substring(field2,1,2) as
> int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,2)
> as int),cast(0 as datetime))
> )
>
>
> -- example
> select datediff(mi,
> dateadd(ss,cast(substring('34:15:10',1,2) as
> int)*60*60+cast(substring('34:15:10',4,2) as int)*60+
> cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
> dateadd(ss,cast(substring('24:18:10',1,2) as
> int)*60*60+cast(substring('24:18:10',4,2) as int)*60+
> cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
> )
>
>
> "CC&JM" wrote:

Data Type Convertion Error

Hello,
I need to convert one character field to datetime and after make the
differenc between two fields.
The problem is that if in the output result appears one value that is
biggest then 23:59:59 hours its shown the
following error:
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
Example:
select convert(datetime, field, 108) from table_name
or
select convert (datetime, '24:00:00', 108) from table_name
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
I need to use all the results and know the difference between them in hour
or minutes.
Example:
select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
field_B, 108))
from table_name
Can you help me?
Thanks and best regardsHi
24:00:00 is not a valid time. In effect, it is 00:00:00.000 the next day.
00:00:00.000 to 23:59:59.999 is
You need to fix your data to a ISO valid date value.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CD38A959-9022-4BA9-80B6-1AFCDE0AD8FB@.microsoft.com...
> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards|||try...
select datediff(mi,
dateadd(ss,cast(substring(field1,1,2) as
int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,2)
as int),cast(0 as datetime)),
dateadd(ss,cast(substring(field2,1,2) as
int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,2)
as int),cast(0 as datetime))
)
-- example
select datediff(mi,
dateadd(ss,cast(substring('34:15:10',1,2
) as
int)*60*60+cast(substring('34:15:10',4,2
) as int)*60+
cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
dateadd(ss,cast(substring('24:18:10',1,2
) as
int)*60*60+cast(substring('24:18:10',4,2
) as int)*60+
cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
)
"CC&JM" wrote:

> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards|||Thanks everybody.
Best regards
"Aleksandar Grbic" wrote:
[vbcol=seagreen]
> try...
> select datediff(mi,
> dateadd(ss,cast(substring(field1,1,2) as
> int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,
2)
> as int),cast(0 as datetime)),
> dateadd(ss,cast(substring(field2,1,2) as
> int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,
2)
> as int),cast(0 as datetime))
> )
>
>
> -- example
> select datediff(mi,
> dateadd(ss,cast(substring('34:15:10',1,2
) as
> int)*60*60+cast(substring('34:15:10',4,2
) as int)*60+
> cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
> dateadd(ss,cast(substring('24:18:10',1,2
) as
> int)*60*60+cast(substring('24:18:10',4,2
) as int)*60+
> cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
> )
>
>
> "CC&JM" wrote:
>

Data Type Convertion Error

Hello,
I need to convert one character field to datetime and after make the
differenc between two fields.
The problem is that if in the output result appears one value that is
biggest then 23:59:59 hours its shown the
following error:
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
Example:
select convert(datetime, field, 108) from table_name
or
select convert (datetime, '24:00:00', 108) from table_name
(xxxxxxx row(s) affected)
Server: Msg 242, Level 16, state 3, line 1
The convertion of a char data type to a datetime data type resulted in an
out-of-range datetime value
I need to use all the results and know the difference between them in hour
or minutes.
Example:
select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
field_B, 108))
from table_name
Can you help me?
Thanks and best regardsHi
24:00:00 is not a valid time. In effect, it is 00:00:00.000 the next day.
00:00:00.000 to 23:59:59.999 is
You need to fix your data to a ISO valid date value.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CD38A959-9022-4BA9-80B6-1AFCDE0AD8FB@.microsoft.com...
> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards|||try...
select datediff(mi,
dateadd(ss,cast(substring(field1,1,2) as
int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,2)
as int),cast(0 as datetime)),
dateadd(ss,cast(substring(field2,1,2) as
int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,2)
as int),cast(0 as datetime))
)
-- example
select datediff(mi,
dateadd(ss,cast(substring('34:15:10',1,2) as
int)*60*60+cast(substring('34:15:10',4,2) as int)*60+
cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
dateadd(ss,cast(substring('24:18:10',1,2) as
int)*60*60+cast(substring('24:18:10',4,2) as int)*60+
cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
)
"CC&JM" wrote:
> Hello,
> I need to convert one character field to datetime and after make the
> differenc between two fields.
> The problem is that if in the output result appears one value that is
> biggest then 23:59:59 hours its shown the
> following error:
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> Example:
> select convert(datetime, field, 108) from table_name
> or
> select convert (datetime, '24:00:00', 108) from table_name
>
> (xxxxxxx row(s) affected)
> Server: Msg 242, Level 16, state 3, line 1
> The convertion of a char data type to a datetime data type resulted in an
> out-of-range datetime value
> I need to use all the results and know the difference between them in hour
> or minutes.
> Example:
> select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> field_B, 108))
> from table_name
> Can you help me?
> Thanks and best regards|||Thanks everybody.
Best regards
"Aleksandar Grbic" wrote:
> try...
> select datediff(mi,
> dateadd(ss,cast(substring(field1,1,2) as
> int)*60*60+cast(substring(field1,4,2) as int)*60+ cast(substring(field1,7,2)
> as int),cast(0 as datetime)),
> dateadd(ss,cast(substring(field2,1,2) as
> int)*60*60+cast(substring(field2,4,2) as int)*60+ cast(substring(field2,7,2)
> as int),cast(0 as datetime))
> )
>
>
> -- example
> select datediff(mi,
> dateadd(ss,cast(substring('34:15:10',1,2) as
> int)*60*60+cast(substring('34:15:10',4,2) as int)*60+
> cast(substring('34:15:10',7,2) as int),cast(0 as datetime)),
> dateadd(ss,cast(substring('24:18:10',1,2) as
> int)*60*60+cast(substring('24:18:10',4,2) as int)*60+
> cast(substring('24:18:10',7,2) as int),cast(0 as datetime))
> )
>
>
> "CC&JM" wrote:
> > Hello,
> >
> > I need to convert one character field to datetime and after make the
> > differenc between two fields.
> > The problem is that if in the output result appears one value that is
> > biggest then 23:59:59 hours its shown the
> > following error:
> >
> > (xxxxxxx row(s) affected)
> > Server: Msg 242, Level 16, state 3, line 1
> > The convertion of a char data type to a datetime data type resulted in an
> > out-of-range datetime value
> >
> > Example:
> >
> > select convert(datetime, field, 108) from table_name
> > or
> > select convert (datetime, '24:00:00', 108) from table_name
> >
> >
> > (xxxxxxx row(s) affected)
> > Server: Msg 242, Level 16, state 3, line 1
> > The convertion of a char data type to a datetime data type resulted in an
> > out-of-range datetime value
> >
> > I need to use all the results and know the difference between them in hour
> > or minutes.
> > Example:
> >
> > select datediff( hh, convert(datetime, field_A, 108), convert(datetime,
> > field_B, 108))
> > from table_name
> >
> > Can you help me?
> >
> > Thanks and best regards

Data Type Conversions

I am trying to convert int to date. first I have converted the int value to string(dt_str), using 'Data Conversion' Transformation, then again I have used another 'Data Conversion' Transformation to convert it into date. but its giving the following error

[Data Conversion 1 [3643]] Error: Data conversion failed while converting column "THEDATE_INTO_STR" (2799) to column "CALENDAR_YEAR1" (3657). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".


What are the simple ways to convert from one data type to another? If somebody could give some example of the above...............Try using the Derived Column component to do the casting. Its more flexible than Data Conversion component.

-Jamie|||Right, you might need the flexibility of expressions in derived column.
What is the meaning of the integer as a date?|||int as a date meansI have one int type in source, which has data like20051211....
but my target column is of datetime.
Anyways, it done now...

Thanks

Data Type Conversions

I am trying to convert int to date. first I have converted the int value to string(dt_str), using 'Data Conversion' Transformation, then again I have used another 'Data Conversion' Transformation to convert it into date. but its giving the following error

[Data Conversion 1 [3643]] Error: Data conversion failed while converting column "THEDATE_INTO_STR" (2799) to column "CALENDAR_YEAR1" (3657). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".


What are the simple ways to convert from one data type to another? If somebody could give some example of the above...............Try using the Derived Column component to do the casting. Its more flexible than Data Conversion component.

-Jamie|||Right, you might need the flexibility of expressions in derived column.
What is the meaning of the integer as a date?|||int as a date meansI have one int type in source, which has data like20051211....
but my target column is of datetime.
Anyways, it done now...

Thanks

Data type conversion problem

Hi,
I have a variety of fields that I am trying to convert from Float to Decimal
for greater accuracy however we are having some problems converting them.
We use this fantastic tool called "SQL compare" by Red-Gate software except
that it's failing in one spot. So, we are now working with the remaining
fields that need to be converted field-by-field.
When we try to convert the field called dpst_amt it fails with:
Msg 8115, level 16, State 6, line 1
Arithmetic overflow error converting float to data type numeric.
Statment terminated
The values in [dpst_amt] field are numbers like 693.399999999998, if I try
[select round(dpst_amt,2)] the value never is rounded, if I try to copy the
value out to X field it fails as well. How did I determine what is in these
fields, meaning how do I find the bad record? One must be bad but where or
how do I find it?
Thank you!
ChrisWhat is the size of your decimal datatype? There must be some data in your
column that is larger than the largest that fits in the decimal datatype, so
if your decimal is for example decimal(6,2)
SELECT dpst_amt
FROM your_table
WHERE ABS(dpst_amt) > 9999.99
should give you the values that are outside the range of your decimal.
SELECT MAX(ABS(dps_amt)) FROM your_table
will give you an indication as to what the size of your decimal datatype
should be.
Jacco Schalkwijk
SQL Server MVP
"Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
news:ueaB9$xWFHA.3876@.tk2msftngp13.phx.gbl...
> Hi,
> I have a variety of fields that I am trying to convert from Float to
> Decimal for greater accuracy however we are having some problems
> converting them. We use this fantastic tool called "SQL compare" by
> Red-Gate software except that it's failing in one spot. So, we are now
> working with the remaining fields that need to be converted
> field-by-field.
> When we try to convert the field called dpst_amt it fails with:
> Msg 8115, level 16, State 6, line 1
> Arithmetic overflow error converting float to data type numeric.
> Statment terminated
> The values in [dpst_amt] field are numbers like 693.399999999998, if I try
> [select round(dpst_amt,2)] the value never is rounded, if I try to copy
> the value out to X field it fails as well. How did I determine what is in
> these fields, meaning how do I find the bad record? One must be bad but
> where or how do I find it?
> Thank you!
> Chris
>|||Originally the datatype was Float and what I've found since writing this was
the value of [1.#INF] was stored in the field. How does one search for that
value in the future?
Thank you!
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message news:eukytqyWFHA.2912@.TK2MSFTNGP10.phx.gbl...
> What is the size of your decimal datatype? There must be some data in your
> column that is larger than the largest that fits in the decimal datatype,
> so if your decimal is for example decimal(6,2)
> SELECT dpst_amt
> FROM your_table
> WHERE ABS(dpst_amt) > 9999.99
> should give you the values that are outside the range of your decimal.
> SELECT MAX(ABS(dps_amt)) FROM your_table
> will give you an indication as to what the size of your decimal datatype
> should be.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
> news:ueaB9$xWFHA.3876@.tk2msftngp13.phx.gbl...
>

Data type conversion .. Varchar to GUID

Hi,

I have a parameter @.name varchar(50)

but the table has a field with datatype GUID

how I can convert varchar to guid before insertion...

Thanks

As long as the format of the guid is correct, it should be no problem:

create table test
(
columnName uniqueidentifier
)
go
declare @.guid varchar(50) --char(36) would be better
set @.guid = 'E5F61BB0-38BA-4116-841D-C7E5AAA137A2'

insert into test
select @.guid
go

select *
from test

columnName

E5F61BB0-38BA-4116-841D-C7E5AAA137A2

declare @.guid varchar(50) --char(36) would be better
--invalid guid format:
set @.guid = 'E5F61BB038BA4116841DC7E5AAA137A2'

--failure
insert into test
select @.guid

Msg 8169, Level 16, State 2, Line 6
Conversion failed when converting from a character string to uniqueidentifier.