Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 convert statement to update table wont work

Author  Topic 

jaskalirai
Starting Member

31 Posts

Posted - 2007-12-20 : 06:08:41
use dw_build
go

select
convert(int, _id),
convert(varchar (7), activity_1),
convert(int, activity_1_userno),
convert(varchar (7), activity_2),
convert(int, activity_2_userno),
convert(varchar (7), activity__1),
convert(int, activity__1_userno),
convert(varchar (7), activity__2),
convert(int, activity__2_userno),
convert(varchar (7), activity__3),
convert(int, activity__3_userno),
convert(bit, apmnt_confrmd_stud),
convert(varchar (7), appointment_priori),
convert(int, appointment_priori_userno),
convert(datetime, arrival_time),
convert(varchar (7), assess_outcome),
convert(int, assess_outcome_userno),
convert(bit, attendance_letter),
convert(varchar (7), cancelation_reason),
convert(int, cancelation_reason_userno),
convert(int, clinic),
convert(int, clinic_service),
convert(bit, contract),
convert(datetime, created),
convert(int, creator),
convert(datetime, date__clinic),
convert(datetime, date__staff),
convert(varchar (7), dependency_lev),
convert(int, dependency_lev_userno),
convert(bit, discharge_letter_s),
convert(bit, dna_letter_2_sent),
convert(bit, dna_letter_3_sent),
convert(bit, dna_letter_sent),
convert(varchar (7), dna_reason),
convert(int, dna_reason_userno),
convert(datetime, duration),
convert(int, episode),
convert(datetime, event_date),
convert(varchar (7), exam_category),
convert(int, exam_category_userno),
convert(bit, examination_appt),
convert(bit, first_appt_letter),
convert(bit, flags),
convert(bit, follow_up_booking),
convert(varchar (7), format),
convert(int, format_userno),
convert(int, gp),
convert(bit, hospital_cancellat),
convert(int, linked_clinic_sess),
convert(int, linked_cp_header),
convert(int, linked_referral),
convert(varchar (7), location),
convert(int, location_userno),
convert(int, lost_activity),
convert(varchar (7), new_ongoing_closed),
convert(datetime, next_contact),
convert(varchar (max), notes),
convert(bit, oth_staff_presy),
convert(varchar (7), outcome),
convert(int, outcome_userno),
convert(int, patient),
convert(bit, patient_cancellati),
convert(int, recall_number),
convert(int, referral),
convert(datetime, sched_time__clin),
convert(datetime, sched_time__staff),
convert(datetime, scheduled_time),
convert(varchar (7), sms_contact),
convert(int, sms_contact_userno),
convert(int, staff),
convert(int, staff_gp__1_14),
convert(varchar (7), status),
convert(int, status_userno),
convert(bit, student_excl__with),
convert(datetime, time_seen),
convert(varchar (7), transport),
convert(int, transport_userno),
convert(varchar (7), ubrn__ebooking),
convert(datetime, updated),
convert(int, updator),
convert(bit, user_1),
convert(bit, user_2),
convert(bit, user_3),
convert(bit, user_4),
convert(bit, user_5),
convert(bit, user_6),
convert(varchar (7), v___i_type),
convert(int, v___i_type_userno),
convert(bit, vacc_imm_appt),
convert(datetime, waiting_time),
convert(bit, within_2_hrs)

into appointment_cl

from appointment


i keep getting the following error for all the convert columns

Msg 1038, Level 15, State 5, Line 1
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.

any ideas ?

matty
Posting Yak Master

161 Posts

Posted - 2007-12-20 : 06:13:26
you have to give alias for all columns...
select
convert(int, _id) AS id,
convert(varchar (7), activity_1) AS activity,
...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-20 : 06:16:21
You need to use alias name for the columns
Also it is better to precreate table and then insert

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-20 : 06:17:05


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jaskalirai
Starting Member

31 Posts

Posted - 2007-12-20 : 07:08:24
ok i have done that the other problem is that this table already exists within my database. what i am looking to do is to create a sproc which i can then use within a ssis package any ideas ???
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-20 : 08:17:04
If table already exists use
INSERT Table
SELECT...

What are you trying to achieve with SP in SSIS?
Go to Top of Page
   

- Advertisement -