Wednesday, March 7, 2012

Change the Column_Name Data Type with a query? Possible?

Hi everyone,
Ive got a small question: Is it possible to change the Column_Name Data Type from a SQL table with a query?
I want to do this with a query.
The Data Type ntext must be changed to text
Thanks in advance!i"m not shure what you want

BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_table1
(
kolnew text,
)
GO
IF EXISTS(SELECT * FROM dbo.table1)
EXEC('INSERT INTO dbo.Tmp_table1 (kol)
SELECT CONVERT(text, kolnew) FROM dbo.table1 TABLOCKX')

GO
DROP TABLE dbo.tabla1
GO
EXECUTE sp_rename N'dbo.Tmp_table1', N'table1', 'OBJECT'
commit transaction|||Here you have a screenshot from what I mean: (Edited out - not usefull anymore!)|||so you have the answer|||THX! I'm gonna try it... :D

I hope it works!!

I asked this because off topic 'Euro symbol appears like a '?' instead ''

No comments:

Post a Comment