updating database using sql

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
hello,

while trying to update products table using sql, getting the following error

INSERT INTO Nop_Product
                      (ShortDescription, CreatedOn, UpdatedOn)
VALUES     ('This is a brand new product','25/07/2011 20:49:53', '25/07/2011 20:49:53')

"the conversion of varchar data type to a date time data type resulted in an out of range value"

getting the same error using getdate() instead of date values for CreatedOn and UpdatedOn Columns

also used MM/DD/YYYY format 07/25/2011 still getting the same error

createdon and updated on doesn't accept nulls.


Regards
Il y a 12 ans
lubish wrote:
hello,

while trying to update products table using sql, getting the following error

INSERT INTO Nop_Product
                      (ShortDescription, CreatedOn, UpdatedOn)
VALUES     ('This is a brand new product','25/07/2011 20:49:53', '25/07/2011 20:49:53')
"the conversion of varchar data type to a date time data type resulted in an out of range value"

getting the same error using getdate() instead of date values for CreatedOn and UpdatedOn Columns

also used MM/DD/YYYY format 07/25/2011 still getting the same error

createdon and updated on doesn't accept nulls.


Regards


Did you try using the TSQL Convert?


INSERT INTO Nop_Product
                      (ShortDescription, CreatedOn, UpdatedOn)
VALUES     ('This is a brand new product',CONVERT(DateTime, "25/07/2011", 103), CONVERT(DateTime, "25/07/2011", 103))




Hope this helps,
Chris
Il y a 12 ans
on executing the above query getting the following error

Error Message
Invalid column name '25/07/2011'.
Invalid column name '25/07/2011'

on removing these values getting another error

cannot insert nulls in column Name, column name already has values which we dont want to edit or update

all we want to do is insert values in short description column if possible.

regards,
Il y a 12 ans
lubish wrote:
on executing the above query getting the following error

Error Message
Invalid column name '25/07/2011'.
Invalid column name '25/07/2011'

on removing these values getting another error

cannot insert nulls in column Name, column name already has values which we dont want to edit or update

all we want to do is insert values in short description column if possible.

regards,


(Those double quotes in prior example should be single quotes.  But, to answer your real question...)

UPDATE [dbo].[Nop_Product]
   SET [ShortDescription] = '...'
      ...
WHERE ProductId = nnnnn
Il y a 12 ans
Excellent
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.