SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Export to Excel
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 30

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1050 Posts

Posted - 06/20/2013 :  14:41:04  Show Profile  Reply with Quote
quote:
Originally posted by pascal_jimi

IF @GO=1
BEGIN
SELECT A INTO #WS_DEPTS1 FROM TABLE1
END
ELSE
BEGIN
SELECT A INTO #WS_DEPTS1 FROM TABLE2
END

Msg 2714, Level 16, State 1, Procedure ParseXmlPersonInfo, Line 155
There is already an object named '# WS_DEPTS1' in the database.



kmkmmm



If the code is inside any loop then

Create table #WS_DEPTS1 (colName datatype)
While Loop with some logic
Begin
...
...

IF @GO=1
BEGIN
Insert into #WS_DEPTS1 (colname)
SELECT A INTO #WS_DEPTS1 FROM TABLE1
END
ELSE
BEGIN
Insert into #WS_DEPTS1 (colname)
SELECT A INTO #WS_DEPTS1 FROM TABLE2
END
....
...
ENd





Cheers
MIK
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 08/20/2013 :  09:39:10  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by MIK_2008

quote:
Originally posted by pascal_jimi

IF @GO=1
BEGIN
SELECT A INTO #WS_DEPTS1 FROM TABLE1
END
ELSE
BEGIN
SELECT A INTO #WS_DEPTS1 FROM TABLE2
END

Msg 2714, Level 16, State 1, Procedure ParseXmlPersonInfo, Line 155
There is already an object named '# WS_DEPTS1' in the database.



kmkmmm



If the code is inside any loop then

Create table #WS_DEPTS1 (colName datatype)
While Loop with some logic
Begin
...
...

IF @GO=1
BEGIN
Insert into #WS_DEPTS1 (colname)
SELECT A INTO #WS_DEPTS1 FROM TABLE1
END
ELSE
BEGIN
Insert into #WS_DEPTS1 (colname)
SELECT A INTO #WS_DEPTS1 FROM TABLE2
END
....
...
ENd





Cheers
MIK


You can also use dynamic sql like this http://beyondrelational.com/modules/2/blogs/70/posts/10926/createalter-procedure-in-a-single-batch.aspx

Madhivanan

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

Pamelag52
Starting Member

USA
1 Posts

Posted - 02/26/2014 :  10:47:11  Show Profile  Reply with Quote
I am importing data from an Excel spreadsheet into a SQL table using Microsoft.ACE.OLEDB.12.0. Everything is working fine except the zip code field/column is being translated as a float instead of character field when I insert this data into another table This makes the zip code show as '5.60033e+008' instead of '560032658'. When I issue the command below, the zip code shows as expected. But when I insert the results into another table, it converts it to a float even though the field it is being inserted into is varchar. Any ideas?

SELECT * into TempPayments FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0',
'Data Source=f:\FranklinPayments\2013\210_130731_130806.xlsx;Extended Properties=Excel 12.0')...[PAYMENT_DATA$]
Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1050 Posts

Posted - 03/05/2014 :  08:20:26  Show Profile  Reply with Quote
suspecting that you might need to adjust the field type in excel. Have you check by making the excel field number/text so that it appears correctly and use same datatype in sql table too.

Cheers
MIK
Go to Top of Page
Page: of 30 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000