Thursday, March 8, 2012
convert sql smalldatetime column into numbers
I have a simple question to ask; I need to create a column with the data from my DOB column (which has the smalldatetime type attached to it). I know how to do that but I am not too sure how to convert the data from that column int normal character for example when I copy it into my newly created column and change the type to varchar I get this jan 16 1979 from this date 1979/01/16. But I actually want the data to look like this 19790116, so in effect I just want to take out the slashes.
Any help would be highly appreciated, thanks all.select convert(varchar,getdate(),112) ??
Wednesday, March 7, 2012
Convert single record to table
Hi all!
I have imported a table into SQL Server from a legacy program. Each record has a repeating sequence of similar fields. (Ex. Accnt1, Assesed1, Paid1, Accnt2, Assesed2, Paid2, etc.) I would like to take a single record and put data from these fields into a table that has the columns Accnt, Assesed, and Paid. I am doing this for easier use in a program I am developing in VB 2005. Can this be done in SQL or do I need to have help from some VB code? If it's possible, what might the SQL look like?
Thanks.
Try:
create table dbo.t3 (
pk_col int not null,
grp int not null,
Accnt int,
Assesed int,
Paid int,
constraint pk_t3 primary key (pk_col, grp) clustered
)
insert into dbo.t3(pk_col, grp, Accnt, Assesed, Paid)
select pk_col, 1 as grp, Accnt1as Accnt, Assesed1as Assesed, Paid1 as Paid
from dbo.t1
union all
select pk_col, 2 as grp, Accnt2, Assesed2, Paid2
from dbo.t1
union all
select pk_col, 3 as grp, Accnt3, Assesed3, Paid3
from dbo.t1
order by pk_col, grp
AMB
|||Thanks! it worked great!
Convert single record to table
Hi all!
I have imported a table into SQL Server from a legacy program. Each record has a repeating sequence of similar fields. (Ex. Accnt1, Assesed1, Paid1, Accnt2, Assesed2, Paid2, etc.) I would like to take a single record and put data from these fields into a table that has the columns Accnt, Assesed, and Paid. I am doing this for easier use in a program I am developing in VB 2005. Can this be done in SQL or do I need to have help from some VB code? If it's possible, what might the SQL look like?
Thanks.
Try:
create table dbo.t3 (
pk_col int not null,
grp int not null,
Accnt int,
Assesed int,
Paid int,
constraint pk_t3 primary key (pk_col, grp) clustered
)
insert into dbo.t3(pk_col, grp, Accnt, Assesed, Paid)
select pk_col, 1 as grp, Accnt1as Accnt, Assesed1as Assesed, Paid1 as Paid
from dbo.t1
union all
select pk_col, 2 as grp, Accnt2, Assesed2, Paid2
from dbo.t1
union all
select pk_col, 3 as grp, Accnt3, Assesed3, Paid3
from dbo.t1
order by pk_col, grp
AMB
|||Thanks! it worked great!
Tuesday, February 14, 2012
Convert from MySql to MSQL Server??
I want to convert from a MySql db to a MSQLServer, using something like mysqldump or something similar, so I can convert the database structure and data at the same time...Is this posible?
How can I do it??
Thank you very much!!If you have the MySQL ODBC driver, then I would give DTS a go. I have used DTS to read structure and data from several odd ODBC Datasources and for the most part have had little problems.