Write Sproc Recordset Into A Temp Table

Jul 12, 2006

I need to call a sproc about 1000 times and build a table from all the results.

How do I write an insert statement that will take the recordsets from the sproc and put it into a temp table?

View 1 Replies


ADVERTISEMENT

Loop Through Temp Table / Call Sproc / Do Updates

Mar 5, 2015

I'm trying to do something like this:

Loop through #Temp_1
-Execute Sproc_ABC passing in #Temp_1.Field_TUV as parameter
-Store result set of Sproc_ABC into #Temp_2
-Update #Temp_1 SET #Temp_1.Field_XYZ= #Temp_2.Field_XYZ
End Loop

It appears scary from a performance standpoint, but I'm not sure there's a way around it. I have little experience with loops and cursors in SQL. What would such code look like? And is there a preferable way (assuming I have to call Sproc_ABC using Field_TUV to get the new value for Field_XYZ?

View 2 Replies View Related

Loop Through A Recordset To Populate Columns In A Temp Table

Jul 23, 2005

I want to take the contents from a table of appointments and insert theappointments for any given month into a temp table where all theappointments for each day are inserted into a single row with a columnfor each day of the month.Is there a simple way to do this?I have a recordset that looks like:SELECTa.Date,a.Client --contents: Joe, Frank, Fred, Pete, OscarFROMdbo.tblAppointments aWHEREa.date between ...(first and last day of the selected month)What I want to do is to create a temp table that has 31 columnsto hold appointments and insert into each column any appointments forthe date...CREATE TABLE #Appointments (id int identity, Day1 nvarchar(500), Day2nvarchar(500), Day3 nvarchar(500), etc...)Then loop through the recordset above to insert into Day1, Day 2, Day3,etc. all the appointments for that day, with multiple appointmentsseparated by a comma.INSERT INTO#Appointments(Day1)SELECTa.ClientFROMdbo.tblAppointments aWHEREa.date = (...first day of the month)(LOOP to Day31)The results would look likeDay1 Day2 Day3 ...Row1 Joe, PeteFrank,FredMaybe there's an even better way to handle this sort of situation?Thanks,lq

View 11 Replies View Related

T-SQL (SS2K8) :: How To Write Script Without Using Temp Table Or Cursor

Jun 4, 2015

I have a cte:
With cte as
(
Select distinct Incident_ID,
ACTUAL_SEVERITY ,
Policy
From
table)

There are 3 ACTUAL_SEVERITY value: 1-High, 2-Medium and 3-Low

I need the final result be like:
Policy High Medium/Low

How do I write the script with out using temp table or cursor?

View 6 Replies View Related

How To Get A Recordset In ASP From StoredProc Using Temp Tables ?

Mar 2, 2000

Hi!

The problem that I'm dealing with is that I can't get recordset from SP, where I first create a temporary table, then fill this table and return recordset from this temporary table. My StoredProcedure looks like:

CREATE PROCEDURE MySP
AS
CREATE TABLE #TABLE_TEMP ([BLA] [char] (50) NOT NULL)
INSERT INTO #TABLE_TEMP SELECT bla FROM ……
SELECT * FROM #TABLE_TEMP


When I call this SP from my ASP page, the recordset is CLOSED (!!!!) after I open it using the below statements:

Set Conn = Server.CreateObject("ADODB.Connection")
Baza.CursorLocation = 3
Baza.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=IGOR;Data Source=POP"


Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "MySP", Conn, , ,adCmdStoredProc

if rs.State = adStateClosed then
response.Write "RecordSet is closed !!!! " ‘I ALLWAY GET THIS !!!!
else
if not(rs.EOF) then
rs.MoveFirst
while not(rs.EOF)
Response.Write rs ("BLA") & " 1 <br>"
rs.MoveNext
wend
end if

end if

Conn.Close


Do you have any idea how to keep this recordset from closing?
Thanks Igor

View 2 Replies View Related

How Can I Write A Sproc For Dynamic Columns

Nov 27, 2007

Hi...
Is it possible to eliminate values from a select statements if they are NULL or Blank..
the reason i have use cast as decimals is because that value is a varchar in my database... and i want to eliminate those values from my Final select statement that dont is blank so that i will have a data set which may be only 1 - 10 long...
 ALTER PROCEDURE [dbo].[rpt_ParticipantPlanPeriodInvActivity]
@PlanId int,
@ParticipantId int,
@PeriodId int

AS
DECLARE @tbl table
(
tblId smallint IDENTITY(1,1),
ParticipantId int,
LoanId int,
Name1 char(2),
NDesc1 char(30),
TotAct1 decimal(19,4),
Name2 char(2),
NDesc2 char(30),
TotAct2 decimal(19,4),
Name3 char(2),
NDesc3 char(30),
TotAct3 decimal(19,4),
Name4 Char(2),
NDesc4 char(30),
TotAct4 decimal(19,4),
Name5 char(2),
NDesc5 char(30),
TotAct5 decimal(19,4),
Name6 char(2),
NDesc6 char(30),
TotAct6 decimal(19,4),
Name7 char(2),
NDesc7 char(30),
TotAct7 decimal(19,4),
Name8 char(2),
NDesc8 char(30),
TotAct8 decimal(19,4),
Name9 char(2),
NDesc9 char(30),
TotAct9 decimal(19,4),
Name10 char(2),
NDesc10 char(30),
TotAct10 decimal(19,4),
Name11 char(2),
NDesc11 char(30),
TotAct11 decimal(19,4),
Name12 char(2),
NDesc12 char(30),
TotAct12 decimal(19,4),
Name13 char(2),
NDesc13 char(30),
TotAct13 decimal(19,4),
Name14 char(2),
NDesc14 char(30),
TotAct14 decimal(19,4),
Name15 char(2),
NDesc15 char(30),
TotAct15 decimal(19,4),
Name16 char(2),
NDesc16 char(30),
TotAct16 decimal(19,4),
Name17 char(2),
NDesc17 char(30),
TotAct17 decimal(19,4),
Name18 char(2),
NDesc18 char(30),
TotAct18 decimal(19,4),
Name19 char(2),
NDesc19 char(30),
TotAct19 decimal(19,4),
Name20 char(2),
NDesc20 char(30),
TotAct20 decimal(19,4)
)

Insert Into @tbl
SELECT
pf.ParticipantId,
pf.FundId as LoanId,
--CASE When FundName Is Null Then ShortName ELSE FundName END as FundNames,
--pf.PortfolioId,
--PortfolioName,
Act1 as Name1,
a.Description as NDesc1,
cast(TotAct1 as decimal(19,4)) ,
Act2 as Name2,
b.Description as NDesc2,
Cast(TotAct2 as decimal(19,4)),
Act3 as Name3,
c.Description as NDesc3,
Cast(TotAct3 as decimal(19,4)),
Act4 as Name4,
d.Description as NDesc4,
Cast(TotAct4 as decimal(19,4)),
Act5 as Name5,
e.Description as NDesc5,
Cast(TotAct5 as decimal(19,4)),
Act6 as Name6,
fi.Description as NDesc6,
Cast(TotAct6 as decimal(19,4)),
Act7 as Name7,
g.Description as NDesc7,
Cast(TotAct7 as decimal(19,4)),
Act8 as Name8,
h.Description as NDesc8,
Cast(TotAct8 as decimal(19,4)),
Act9 as Name9,
i.Description as NDesc9,
Cast(TotAct9 as decimal(19,4)),
Act10 as Name10,
j.Description as NDesc10,
Cast(TotAct10 as decimal(19,4)),
Act11 as Name11,
k.Description as NDesc11,
Cast(TotAct11 as decimal(19,4)),
Act12 as Name12,
l.Description as NDesc12,
Cast(TotAct12 as decimal(19,4)),
Act13 as Name13,
m.Description as NDesc13,
Cast(TotAct13 as decimal(19,4)),
Act14 as Name14,
n.Description as NDesc14,
Cast(TotAct14 as decimal(19,4)),
Act15 as Name15,
o.Description as NDesc15,
Cast(TotAct15 as decimal(19,4)),
Act16 as Name16,
p1.Description as NDesc16,
Cast(TotAct16 as decimal(19,4)),
Act17 as Name17,
q.Description as NDesc17,
Cast(TotAct17 as decimal(19,4)),
Act18 as Name18,
r.Description as NDesc18,
Cast(TotAct18 as decimal(19,4)),
Act19 as Name19,
s.Description as NDesc19,
Cast(TotAct19 as decimal(19,4)),
Act20 as Name20,
t.Description as NDesc20,
Cast(TotAct20 as decimal(19,4))
FROM

ParticipantPlanFundBalances1 pf
Left Outer JOIN Fund f
On f.FundId = pf.FundId
LEFT Join PlanPortfolio p
On pf.PortfolioId = p.PortfolioId
Left outer Join AscActCodes a
on pf.Act1 = a.Name
left outer Join AscActCodes b
on pf.Act2 = b.Name
left outer Join AscActCodes c
on pf.Act3 = c.Name
left outer Join AscActCodes d
on pf.Act4 = d.Name
left outer Join AscActCodes e
on pf.Act5 = e.Name
left outer Join AscActCodes fi
on pf.Act6 = fi.Name
left outer Join AscActCodes g
on pf.Act7 = g.Name
left outer Join AscActCodes h
on pf.Act8 = h.Name
left Outer Join AscActCodes i
on pf.Act9 = i.Name
left Outer Join AscActCodes j
on pf.Act10 = j.Name
left outer Join AscActCodes k
on pf.Act11 = k.Name
left outer Join AscActCodes l
on pf.Act12 = l.Name
left outer Join AscActCodes m
on pf.Act13 = m.Name
left outer Join AscActCodes n
on pf.Act14 = n.Name
left outer Join AscActCodes o
on pf.Act15 = o.Name
left outer Join AscActCodes p1
on pf.Act16 = p1.Name
left outer Join AscActCodes q
on pf.Act17 = q.Name
left outer Join AscActCodes r
on pf.Act18 = r.Name
left outer Join AscActCodes s
on pf.Act19 = s.Name
left outer Join AscActCodes t
on pf.Act20 = t.Name
WHERE
pf.FundId = 0
AND
PeriodId = @PeriodId
AND
pf.PlanId = @PlanId
AND
pf.ParticipantId = @ParticipantId


--Get the Fund information for the report and combine it with the Loan information
-- in the table variable...

SELECT
pf.ParticipantId,
pf.PortfolioId,
PortfolioName,
pf.FundId LoanFundId,
CASE When FundName Is Null Then ShortName ELSE FundName END as FundNames,
Act1 as Name1,
a.Description as NDesc1,
Cast(TotAct1 as decimal(19,4)),
Act2 as Name2,
b.Description as NDesc2,
Cast(TotAct2 as decimal(19,4)),
Act3 as Name3,
c.Description as NDesc3,
Cast(TotAct3 as decimal(19,4)),
Act4 as Name4,
d.Description as NDesc4,
Cast(TotAct4 as decimal(19,4)),
Act5 as Name5,
e.Description as NDesc5,
Cast(TotAct5 as decimal(19,4)),
Act6 as Name6,
fi.Description as NDesc6,
Cast(TotAct6 as decimal(19,4)),
Act7 as Name7,
g.Description as NDesc7,
Cast(TotAct7 as decimal(19,4)),
Act8 as Name8,
h.Description as NDesc8,
Cast(TotAct8 as decimal(19,4)),
Act9 as Name9,
i.Description as NDesc9,
Cast(TotAct9 as decimal(19,4)),
Act10 as Name10,
j.Description as NDesc10,
Cast(TotAct10 as decimal(19,4)),
Act11 as Name11,
k.Description as NDesc11,
Cast(TotAct11 as decimal(19,4)),
Act12 as Name12,
l.Description as NDesc12,
Cast(TotAct12 as decimal(19,4)),
Act13 as Name13,
m.Description as NDesc13,
Cast(TotAct13 as decimal(19,4)),
Act14 as Name14,
n.Description as NDesc14,
Cast(TotAct14 as decimal(19,4)),
Act15 as Name15,
o.Description as NDesc15,
Cast(TotAct15 as decimal(19,4)),
Act16 as Name16,
p1.Description as NDesc16,
Cast(TotAct16 as decimal(19,4)),
Act17 as Name17,
q.Description as NDesc17,
Cast(TotAct17 as decimal(19,4)),
Act18 as Name18,
r.Description as NDesc18,
Cast(TotAct18 as decimal(19,4)),
Act19 as Name19,
s.Description as NDesc19,
Cast(TotAct19 as decimal(19,4)),
Act20 as Name20,
t.Description as NDesc20,
Cast(TotAct20 as decimal(19,4))

FROM

ParticipantPlanFundBalances1 pf
Left Outer JOIN Fund f
On f.FundId = pf.FundId
LEFT Join PlanPortfolio p
On pf.PortfolioId = p.PortfolioId
Left outer Join AscActCodes a
on pf.Act1 = a.Name
left outer Join AscActCodes b
on pf.Act2 = b.Name
left outer Join AscActCodes c
on pf.Act3 = c.Name
left outer Join AscActCodes d
on pf.Act4 = d.Name
left outer Join AscActCodes e
on pf.Act5 = e.Name
left outer Join AscActCodes fi
on pf.Act6 = fi.Name
left outer Join AscActCodes g
on pf.Act7 = g.Name
left outer Join AscActCodes h
on pf.Act8 = h.Name
left Outer Join AscActCodes i
on pf.Act9 = i.Name
left Outer Join AscActCodes j
on pf.Act10 = j.Name
left outer Join AscActCodes k
on pf.Act11 = k.Name
left outer Join AscActCodes l
on pf.Act12 = l.Name
left outer Join AscActCodes m
on pf.Act13 = m.Name
left outer Join AscActCodes n
on pf.Act14 = n.Name
left outer Join AscActCodes o
on pf.Act15 = o.Name
left outer Join AscActCodes p1
on pf.Act16 = p1.Name
left outer Join AscActCodes q
on pf.Act17 = q.Name
left outer Join AscActCodes r
on pf.Act18 = r.Name
left outer Join AscActCodes s
on pf.Act19 = s.Name
left outer Join AscActCodes t
on pf.Act20 = t.Name
WHERE
pf.FundId <> 0
AND
PeriodId = @PeriodId
AND
pf.PlanId = @PlanId
AND
ParticipantId = @ParticipantId




Union

SELECT
ParticipantId,
0,
'NA',
LoanId,
'Loan ' + cast(tblId as char(1)),
Name1,
NDesc1,
Cast(TotAct1 as decimal(19,4)),
Name2,
NDesc2,
Cast(TotAct2 as decimal(19,4)),
Name3,
NDesc3,
Cast(TotAct3 as decimal(19,4)),
Name4,
NDesc4,
Cast(TotAct4 as decimal(19,4)),
Name5,
NDesc5,
Cast(TotAct5 as decimal(19,4)),
Name6,
NDesc6,
Cast(TotAct6 as decimal(19,4)),
Name7,
NDesc7,
Cast(TotAct7 as decimal(19,4)),
Name8,
NDesc8,
Cast(TotAct8 as decimal(19,4)),
Name9,
NDesc9,
Cast(TotAct9 as decimal(19,4)),
Name10,
NDesc10,
Cast(TotAct10 as decimal(19,4)),
Name11,
NDesc11,
Cast(TotAct11 as decimal(19,4)),
Name12,
NDesc12,
Cast(TotAct12 as decimal(19,4)),
Name13,
NDesc13,
Cast(TotAct13 as decimal(19,4)),
Name14,
NDesc14,
Cast(TotAct14 as decimal(19,4)),
Name15,
NDesc15,
Cast(TotAct15 as decimal(19,4)),
Name16,
NDesc16,
Cast(TotAct16 as decimal(19,4)),
Name17,
NDesc17,
Cast(TotAct17 as decimal(19,4)),
Name18,
NDesc18,
Cast(TotAct18 as decimal(19,4)),
Name19,
NDesc19,
Cast(TotAct19 as decimal(19,4)),
Name20,
NDesc20,
Cast(TotAct20 as decimal(19,4))
FROM @tbl

Any help will be appreciated. 
Regards
Karen
 

View 10 Replies View Related

Insert Into #temp Exec Sproc Not Working

Aug 15, 2005

Hi,I have a sproc with 5 params that takes about 40 seconds to return.But when I Create a Temp table and do aInsert Into #tempExec sproc param1, param2, param3, param4, param5it never returns...any ideas?Thanks,Bill

View 1 Replies View Related

Cannot Write To Column In Updatable RecordSet

Feb 3, 2004

Hi. I receive the SQLException:

[Microsoft][SQLServer 2000 Driver for JDBC]Can not update, the specified column is not writable.

when I attempt to call updateString() on a RecordSet column. I have set the Statement object on which I execute the query to obtain the RecordSet to be scrollable and updatable.

My goal is to replace the ID value contained in a particular column of each row with a longer text string that includes the ID value. If I can't alter the column values via the RecordSet, can I write SQL as part of the query to generate the text string?

Thank you.

Raj

View 2 Replies View Related

How To Create A Recordset That Joins 3 Temp Tables

Sep 26, 2006

I have an stp where I want to return a Recordset via a SELECT that joins 3 temp tables...

Here's what the temp tables look like (I am being brief)...

CREATE TABLE #Employees (EmpID INTEGER, EmpName NVARCHAR(40))

CREATE TABLE #PayPeriods (PayPeriodIndex INTEGER, StartDate DATETIME, EndDate DATETIME)

CREATE TABLE #Statistics (EmpID INTEGER, PayPeriodIndex INTEGER, HoursWorked REAL)

The #Employees table is populated for all employees.

The #PayPeriods table is populated for each calandar week of the year (PayPeriodIndex=0 to 51).

The #Statistics table is populated from data within another permanent table.

Some employees do not work all 52 weeks.

Some employees do not work any of the 52 weeks.

So, the #Statistics table doesn't have all possible combinations of Employees and PayPeriods.

I want to return a Recordset for all possible combinations of Employees and PayPeriods...

Here's a SELECT that I have used...

SELECT e.EmpId, e.Name, pp.PayPeriodIndex, ISNULL(s.HoursWorked,0)

FROM #Statistics s

LEFT OUTER JOIN #Employees e....

LEFT OUTER JOIN #PayPeriods pp ....

WHERE s.EmpId = e.EmpId

AND s.PayPeriodIndex = pp.PayPeriodIndex

I have had no luck with this SELECT.

Can anybody help???

TIA

View 4 Replies View Related

T-SQL (SS2K8) :: Moving Values From Temp Table To Another Temp Table?

Apr 9, 2014

Below are my temp tables

--DROP TABLE #Base_Resource, #Resource, #Resource_Trans;
SELECT data.*
INTO #Base_Resource
FROM (
SELECT '11A','Samsung' UNION ALL

[Code] ....

I want to loop through the data from #Base_Resource and do the follwing logic.

1. get the Resourcekey from #Base_Resource and insert into #Resource table

2. Get the SCOPE_IDENTITY(),value and insert into to

#Resource_Trans table's column(StringId,value)

I am able to do this using while loop. Is there any way to avoid the while loop to make this work?

View 2 Replies View Related

Temp Table Vs Global Temp Table

Jun 24, 1999

I think this is a very simple question, however, I don't know the
answer. What is the difference between a regular Temp table
and a Global Temp table? I need to create a temp table within
an sp that all users will use. I want the table recreated each
time someone accesses the sp, though, because some of the
same info may need to be inserted and I don't want any PK errors.

thanks!!
Toni Eibner

View 2 Replies View Related

When A Sproc Or Table Was Last Used

Sep 21, 2005

How can I determine when a sproc or table was last used?
I suspect that I have many obsolete tables and sprocs in my database but how can I find out for sure??
Thanks,
DL

View 5 Replies View Related

Need Help Posting To Sql Table With A Sproc

Jan 4, 2005

To all,

Here's the error:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 159:
Line 160:objConn.Open()
Line 161:objCmd.ExecuteNonQuery()
Line 162:objConn.Close()
Line 163:


Source File: C:FullerAviationSupplymanagecatalog.vb Line: 161

Stack Trace:


[FormatException: Input string was not in a correct format.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +194
managecatalog.SubmitProd(Object s, EventArgs e) in C:FullerAviationSupplymanagecatalog.vb:161
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573





Here's the code from my vb file:


Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region


Protected WithEvents dgProductCatalog As datagrid
Protected WithEvents tbxProductName As TextBox
Protected WithEvents tbxInventory As TextBox
Protected WithEvents dgCatProd_Active As DropDownList
Protected WithEvents dlvendor As DropDownList
Protected WithEvents dlSubcat As DropDownList
Protected WithEvents btnLinkvend As Button
Protected WithEvents tbxshortdesc As TextBox
Protected WithEvents tbxlongdesc As TextBox
Protected WithEvents qtyPA As TextBox
Protected WithEvents pricePA As TextBox
Protected WithEvents qtyPB As TextBox
Protected WithEvents pricePB As TextBox
Protected WithEvents qtyPC As TextBox
Protected WithEvents pricePC As TextBox
Protected WithEvents sizeX As TextBox
Protected WithEvents dlX As DropDownList
Protected WithEvents sizeY As TextBox
Protected WithEvents dlY As DropDownList
Protected WithEvents sizeZ As TextBox
Protected WithEvents dlZ As DropDownList
Protected WithEvents weight As TextBox
Protected WithEvents dlweight As DropDownList
Protected WithEvents dgInsertProduct As Button
Protected WithEvents thumbfile As TextBox
Protected WithEvents mainfile As TextBox



Dim objDA As SqlDataAdapter
Dim objDS As New DataSet()
Dim objDX As New DataSet()
Dim objDV As New DataSet()
Dim objDU As New DAtaSet()
Dim objDW As New DAtaSet()
Dim objDT As DataTable
Dim objDR As DataRow
Dim objConn As SqlConnection = New SqlConnection(ConStr)

Sub Page_Load()

If Not IsPostBack Then
BindData()
End IF

End Sub

Sub BindData()


objDA = New SqlDataAdapter("GETCATALOG",objConn)
objDA.Fill(objDS, "MainCatalog")
objDT = objDS.Tables("Catalog")
dgProductCatalog.DataSource = objDS
dgProductCatalog.DataBind()


objDA = New SqlDataAdapter("GETSUBCAT",objConn)
objDA.Fill(objDX, "SubCat")
dlSubcat.DataSource = objDX
dlSubcat.DataValueField = "SubCat_ID"
dlSubcat.DataTextField = "SubCat_Name"
dlSubcat.DataBind()

objDA = New SqlDataAdapter("GETVENDOR",objConn)
objDA.Fill(objDV, "Vendor")
dlvendor.DataSource = objDV
dlvendor.DataValueField = "VendorID"
dlvendor.DataTextField = "CompanyName"
dlvendor.DataBind()

objDA = New SqlDataAdapter("GETSIZEUNITS",objConn)
objDA.Fill(objDU, "Units")
dlX.DataSource = objDU
dlX.DataValueField = "Size_ID"
dlX.DataTextField = "Size_Unit"
dlX.DataBind()

dlY.DataSource = objDU
dlY.DataValueField = "Size_ID"
dlY.DataTextField = "Size_Unit"
dlY.DataBind()

dlZ.DataSource = objDU
dlZ.DataValueField = "Size_ID"
dlZ.DataTextField = "Size_Unit"
dlZ.DataBind()

objDA = New SqlDataAdapter("GETWEIGHTUNITS",objConn)
objDA.Fill(objDW, "Units")
dlweight.DataSource = objDW
dlweight.DataValueField = "weight_unitID"
dlweight.DataTextField = "weight_Unit"
dlweight.DataBind()

End Sub

Sub SubmitProd(s As Object, e As EventArgs)

Dim objCmd As New SqlCommand("INSERTPRODUCT", objConn)
objCmd.CommandType = CommandType.StoredProcedure
objCmd.Parameters.Add("@prodName", tbxProductName.Text)
objCmd.Parameters.Add("@descShort", tbxshortdesc.Text)
objCmd.Parameters.Add("@descLong", tbxlongdesc.Text)
objCmd.Parameters.Add("@qtyPA", SqlDbType.int ).Value = qtyPA.Text
objCmd.Parameters.Add("@qtyPB", SqlDbType.int ).Value = qtyPB.Text
objCmd.Parameters.Add("@qtyPC", SqlDbType.int ).Value = qtyPC.Text
objCmd.Parameters.Add("@pricePA",SqlDbType.money).Value = pricePA.Text
objCmd.Parameters.Add("@pricePB",SqlDbType.money).Value = pricePB.Text
objCmd.Parameters.Add("@pricePC",SqlDbType.money).Value = pricePC.Text
objCmd.Parameters.Add("@vendorID", dlvendor.SelectedItem.Value)
objCmd.Parameters.Add("@inventoryAvail", SqlDbType.int).Value = tbxInventory.Text
objCmd.Parameters.Add("@imageThumb", thumbfile.Text)
objCmd.Parameters.Add("@imageLarge", mainfile.Text)
objCmd.Parameters.Add("@sizeX", sizeX.Text)
objCmd.Parameters.Add("@sizeY", sizeY.Text)
objCmd.Parameters.Add("@sizeZ", sizeZ.Text)
objCmd.Parameters.Add("@sizeUX", dlX.SelectedItem.Value)
objCmd.Parameters.Add("@sizeUY", dlY.SelectedItem.Value)
objCmd.Parameters.Add("@sizeUZ", dlZ.SelectedItem.Value)
objCmd.Parameters.Add("@weight", weight.Text)
objCmd.Parameters.Add("@prodActive", dgCatProd_Active.SelectedItem.Value)
objCmd.Parameters.Add("@weightU", dlweight.SelectedItem.Value)
objCmd.Parameters.Add("@SubCat_ID", dlSubcat.SelectedItem.Value)


objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()

tbxProductName.Text=""
tbxInventory.Text=""
tbxshortdesc.Text=""
tbxlongdesc.Text=""
qtyPA.Text=""
pricePA.Text=""
qtyPB.Text=""
pricePB.Text=""
qtyPC.Text=""
sizeX.Text=""
sizeZ.Text=""
sizeZ.Text=""
weight.Text=""
BindData()

End Sub




And here's the Stored Procedure:

CREATE PROCEDURE INSERTPRODUCT
(
@prodName nvarchar(50),
@descShort nvarchar(3000),
@descLong nvarchar(4000),
@qtyPA int,
@qtyPB int,
@qtyPC int,
@pricePA money,
@pricePB money,
@pricePC money,
@vendorID int,
@inventoryAvail int,
@imageThumb nvarchar,
@imageLarge nvarchar,
@sizeX nvarchar,
@sizeY nvarchar,
@sizeZ nvarchar,
@sizeUX int,
@sizeUY int,
@sizeUZ int,
@weight nvarchar,
@prodActive int,
@weightU int,
@SubCat_ID int
)

AS

INSERT INTO ProductCatalog (ProductName, Desc_Short, Desc_Long, qty_PerA, qty_PerB, qty_PerC, Price_PerA, Price_PerB, Price_PerC, VendorID, InventoryAvail, image_Thumb, image_Large, Size_X, Size_Y, Size_Z, SizeUnit_X, SizeUnit_Y, SizeUnit_Z, weight, Prod_Active, weight_unit, SubCat_ID) VALUES (@prodName, @descShort, @descLong, @qtyPA, @qtyPB, @qtyPC, @pricePA, @pricePB, @pricePC, @vendorID, @inventoryAvail, @imageThumb, @imageLarge, @sizeX, @sizeY, @sizeZ, @sizeUX, @sizeUY, @sizeUZ, @weight, @prodActive, @weightU, @SubCat_ID)
GO


Any help would be greatly appreciated.

Regards,
Seth

View 2 Replies View Related

Using A Table As SProc Parameters

May 2, 2005

Okay, here's the scenario....

I have a bunch of un-related tables that I need to make relational.

I have a bunch of SProcs set up to help with the relating of the tables but I need the quickest way to get the values from the tables and into the SProcs.

Currently, I'm using .NET to cycle through the necessary tables, sending in their values into the SProcs, one at a time.

I'd like to have some SQL-ized way to do this so I can just make another step in my DTS package that already copies over the un-related tables from DB2.

What I'd imagine the code to look like would be something like...

EXEC SP_EMPLOYEES (SELECT FIRST_NAME,LAST_NAME FROM oldEmployees)


I know, now, that it's not as easy as that but I'm thinking there MUST be a way - even if it requires creating a new SProc.
TIA

View 1 Replies View Related

Sproc Update From Other Table

Apr 7, 2008

Hi,
I've got 2 tables
Table_A with 2 fields: ThreadID & Rating

This Table is updated as users rate forum threads.

Then I have Table_B which should display the some info in a Gridview
Table_B has 3 fields: Name, ID and Score

I want the Rating from Table_A to update to Table_B's Score Field.

I suppose I should write a sproc to do this, but I am not quite sure how;
This is what I would like the sproc to do...

Update Table_B
SET Score = Table_A.Rating WHERE ID = Table_A.ThreadID

Any help on this...or is there a should I not use a sproc.
Also...how do I get the sproc to update the table automatically (without me running the sproc manually)?

View 10 Replies View Related

How To Put Data From A Recordset Into A Table

Jun 24, 2004

I want to transfer a recordset (derived from an Oracle datasource) into
an SQL2000 Server table using VBScript in a ActiveX Script Task using a DTS.

Currently I use the OPENROWSET (and OPENQUERY) method, however
the lenght of the querytext seems to be limited to 8192 bytes.
At this moment I have reached the limit of this lenght, and I am looking
for a solution.

Futher info: The query returns large recordsets of 100,000s of records with 100s of columns. Because of it's complex structure, the standard data transformation in SLQ2000 is not an option.

Using a substitute like:

varRecords = rst1.GetRows
For intI = 0 To UBound(varRecords, 2)
rst2.AddNew
For intJ = 0 To UBound(varRecords, 1)
rst2(intJ) = varRecords(intJ, intI)
Next
Next
rst2.Update

works fine but is much to slow.

Can anyone help me to find a solution?

View 2 Replies View Related

How To Call A Sproc From Within A UDF That Returns A Table?

Oct 5, 2007

Hi. This is a SQL question.
I am trying to wrap a stored procedure with a UDF so I can do selects against the result. The following doesn't work, but is it possible to do something like:
Create Function test()returns @tmp table ( myfield int)asbegin  insert into @tmp (field1)    Exec dbo.MySprocWhichRequires3ParmsAndReturnsATable 5, 6, 10 output  returnend
Thanks

View 1 Replies View Related

Rebuild Table Daily (sproc)

Dec 12, 2007

My goal is to recreate a table daily so that the data is updated.  This could be a bad decision performance-wise, but I felt this was simpler than running a daily update statement.  I created a stored procedure:SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE sp_CreatetblImprintPhrase

AS

DROP TABLE tblImprintPhrase

GO

CREATE TABLE tblImprintPhrase
(
CustID char(12),
CustName varchar(40),
TranNoRel char(15)
)
GO However, I was looking to edit the stored procedure, changing CREATE to ALTER, but when I do so, I am prompted with: Error 170: Line 2: Incorrect syntax near "(". If I change back to CREATE, the error goes away, but the sproc cannot be run because it already exists. Any thoughts?   

View 2 Replies View Related

Update Column Of A Table With A Sproc

Jun 10, 2008

I have a table with this structure

ID | Ticker
-------------------
1330 |AAB-Bank
1336 |AEGON
1367 |ALZSE
1420 |ASSGEN
2812 |AVLN

I have a sproc called usp_validTicker that will take 2 parameters: ticker and date. It will return the valid ticker for that date.
I like to have the sproc going through each ticker in the table and return the valid tickers.

For example
exec usp_validTicker 'AAB-Bank','2008-6-10' will return 'AAB' and my final table will be

ID | Ticker
-------------------
1330 |AAB
1336 |AEGON
1367 |ALZSE
1420 |ASSGEN
2812 |AVLN

View 13 Replies View Related

Is There Any Way In A Sproc To LOOP Thru The Records Of A Table ?

Sep 21, 2005

Hi. It seems to be very simple, actually, but I don't know if it isfeasible in TSQL. I have a sproc which gathers in one place many callsto different other sprocs, all of them taking a 'StoreGroupe'parameter. I would like to add a case where if the call has NOStoreGroupe parameter, the sproc should LOOP thru all records in tableStoreGroupeTable, read the column StoreCode, and pass that value as aparam to the other sprocs, as in:CREATE PROCEDURE MySproc(@StoreGroupe nvarchar(6) = NULL)ASif (@StoreGroupe is not null)BeginExec _Sproc1 @StoreGroupeExec _Sproc2 @StoreGroupeExec _Sproc3 @StoreGroupeExec _Sproc4 @StoreGroupe...............EndElseBeginA 'Group Code' has NOT been specifiedI want to take all the StoreGroups in tableStoreGroupeTable, in turn.I would like to do SOMETHING LIKE THIS:Do While not [StoreGroupeTable].EOFRead [Code] from [StoreGroupeTable]Set @StoreGroupe = The value I just readExec _Sproc1 @StoreGroupeExec _Sproc2 @StoreGroupeExec _Sproc3 @StoreGroupeExec _Sproc4 @StoreGroupe...............LoopEndGOIs that feasible in a sproc, or do I have to do this in the client(ADO) ?Thanks a lot.Alex.

View 4 Replies View Related

How Can I Retrieve A Recordset From A Matrix-like Table?

Feb 3, 2004

I have a table defined as (int Row, int Column, money Data); as it were a matrix.

Which is the more efficient way of retrieving a result set with the following form?

Column1 Column2 Column3
---------- ----------- ----------
Data11 Data12 Data13
Data21 Data22 Data23
Data31 Data32 Data33
... ... ...


Thanks a lot in advance.

View 1 Replies View Related

TRUNCATE TABLE In A Sproc W/locked-down User

Sep 18, 2006

Hullo folks, I'm having what I assume is a fairly mundane security issue.

I have a SQL login that I am trying to restrict as much as possible. This account's sole goal in life is to hit the server, return some usage statistics, then truncate the table it received the statistics from. I would like to refrain from granting this login permissions on the physical target table if possible.

Usually I can wrap up "protected" operations in a stored procedure, then grant exec permissions for my user and I'm good to go. However, TRUNCATE TABLE gets cranky with me when I attempt the above method. I suspect that has to do with the fact that TRUNCATE TABLE is effectively modifying the table itself as opposed to merely deleting data.

Is it possible to grant this login ONLY execute permission on a stored proc that TRUNCATE's tables without giving the user any physical permissions? Am I going about this the wrong way?

View 7 Replies View Related

Exec Sproc (sprocname Store In The Table)

May 22, 2008



Hi,

I'm trying to capture the value returned from sprocs. I stored the sproc name in the table and use cursor to run each sproc. Now the question is how can I capture and store the return value in a variable?

Here is the scenario:

Table1 has 1 column varchar(50) called vchsprocname
count_A -- procedure, select count(*) from ...
count_B -- procedure, select count(*) from ...
count_C -- procedure, select count(*) from ...

here is my query:
----------------------------------------------------
DECLARE @vchsprocname varchar(50)
DECLARE @count int

DECLARE cur CURSOR FOR
SELECT vchsprocname from table1

OPEN cur
FETCH NEXT FROM cur
into @vchsprocname

WHILE @@FETCH_STATUS = 0
BEGIN

exec @count = @vchsprocname -- I know I cannot do this, the vchsprocname cannot be variable. What else can I do?

FETCH NEXT FROM cur
into @vchsprocname
END

--------------------------------------------------

View 7 Replies View Related

Inserting Data Returned From A Sproc Into A Table

Apr 12, 2006



i am writing a sproc that calls another sproc. this 2nd sproc returns 3 or 4 rows. i want to be able to insert these rows into a table. this sproc is inside a cursor, as i have to call it many times.



how do i insert the rows that it returns into another table??

View 10 Replies View Related

Read Table Description Into ADODB.Recordset.

Aug 20, 2003

How do I read the Tables description into ADODB.Recordset and then recreate the Tables+description into a new database from the ADODB.Recordset.

View 1 Replies View Related

Transact SQL :: Return Recordset From Dynamic Table

Sep 25, 2015

I tried to create a dynamic table, fill in it and return it as recordset. The codes as this:

Declare @tbl Table(id int, name varchar(100), age int) 
Insert Into @tbl(id, name, age)
Values(1, 'James, Lee', 28),
   (2, 'Mike, Richard', 32),
   (3, 'Leon Wong', 29)
Select * From @tbl Order By age

It works well in "SQL Query Ananizer". But return no records in ASP page.

View 5 Replies View Related

How Can You Insert A Dummy Row At The Top Of Every Related Recordset In A Table?

Jan 22, 2008

I have the following:

TicketID_1 AuditRec1
TicketID_1 AuditRec2
TicketID_1 AuditRec3
TicketID_1 AuditRec4
TicketID_1 AuditRec5
TicketID_2 AuditRec1
TicketID_2 AuditRec2
TicketID_2 AuditRec3
TicketID_2 AuditRec4
TicketID_2 AuditRec5

I need to insert a dummy row as the first row in this AuditRecord table for every occurrance of a given TicketID so that I get the following:

Dummy_Tick1 Dummy_AuditRec
TicketID_1 AuditRec1
TicketID_1 AuditRec2
TicketID_1 AuditRec3
TicketID_1 AuditRec4
TicketID_1 AuditRec5
Dummy_Tick2 Dummy_AuditRec
TicketID_2 AuditRec1
TicketID_2 AuditRec2
TicketID_2 AuditRec3
TicketID_2 AuditRec4
TicketID_2 AuditRec5

The AuditRec table is huge. How can I accomplish this using SQL?

View 1 Replies View Related

T-SQL (SS2K8) :: Outputting Sproc Result Set To A New Physical Table

Aug 3, 2015

I need to output a sproc into a new physical table, so the column definitions match the output.

Select Into DbName.NewTableName
Followed by an
Insert Into DbName.NewTableName
From (SprocNameHere),

View 9 Replies View Related

Retrieve A Recordset From One Table Based On The CSV Values In The Field Of Another

Feb 6, 2007

Hello!

I have 2 tables, one that contains a set of codes and their definitions, and another where each record has a field that contains several of these codes separated by commas:

Tab1

SubCode | Definition
---------------
S100 | Def of S100
S101 | Def of S101
S102 | Def of S102

Tab2

DepID | Purpcode |SubCodes
-----------------------------
1 | P100 | S100,S101,S102
1 | P101 | S100, S101
2 | P101 | S100,S102

I'm trying to create a query against Tab1 so that it retrieves a recordset of Subcodes and definitions based on the contents of the Subcodes field for a record in Tab2. I've tried this using a subquery, as follows:

SELECT SubCode ,Definition
FROM Tab1
WHERE SubjectCode IN
(SELECT CHAR(39) + REPLACE(SubjectCodes, CHAR(44), CHAR(39 + CHAR(44)+ CHAR(39)) + CHAR(39)
FROM Tab2
WHERE DepID = 1 AND PurposeCode = 'P101')

The subquery will return: 'S100','S101' and I expect the final recordset to be:

SubCode | Definition
---------------
S100 | Def of S100
S101 | Def of S101

However, it's not returning any records. If I execute the subquery separately and then plug its results into the main query e.g.

SELECT SubCode ,Definition
FROM Tab1
WHERE SubjectCode IN ('S100','S101')

it returns the expected recordset. Does anyone have any pointers? It's driving me nuts..

Cheers
Greg

Complete DDL, Sample Data, and Query below:


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SubjectCodeDefinition]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[SubjectCodeDefinition]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DepartmentReturn]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[DepartmentReturn]
GO

CREATE TABLE [dbo].[SubjectCodeDefinition] (
[SubjectCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Definition] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[DepartmentReturn] (
[DeptID] [int] NULL ,
[PurposeCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SubjectCodes] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
) ON [PRIMARY]
GO

INSERT INTO SubjectCodeDefinition(SubjectCode, Definition)
SELECT 'S100', 'Definition of Code S100' UNION ALL
SELECT 'S101', 'Definition of Code S101' UNION ALL
SELECT 'S102', 'Definition of Code S102' UNION ALL
SELECT 'S103', 'Definition of Code S103' UNION ALL
SELECT 'S104', 'Definition of Code S104' UNION ALL
SELECT 'S105', 'Definition of Code S105'
GO

INSERT INTO DepartmentReturn(DeptID,PurposeCode,SubjectCodes)
SELECT 1,'P100','S100,S101,S104' UNION ALL
SELECT 1,'P101','S102,S103' UNION ALL
SELECT 1,'P102','S100,S101,S105' UNION ALL
SELECT 2,'P100','S100,S101,S104,S105' UNION ALL
SELECT 2,'P103','S103,S104,S105' UNION ALL
SELECT 3,'P100','S100,S102,S104'
GO

SELECT SubjectCode ,Definition
FROM SubjectCodeDefinition
WHERE SubjectCode IN
(SELECT CHAR(39) + REPLACE(SubjectCodes, CHAR(44), CHAR(39)+ CHAR(44)+ CHAR(39)) + CHAR(39)
FROM DepartmentReturn
WHERE DeptID = 1 AND PurposeCode = 'P102')

View 1 Replies View Related

SQL Server 2012 :: Stored Procedures Compiles Even When There Is No CREATE TABLE For A Temp Table

Feb 11, 2015

i am inserting something into the temp table even without creating it before. But this does not give any compilation error. Only when I want to execute the stored procedure I get the error message that there is an invalid temp table. Should this not result in a compilation error rather during the execution time.?

--create the procedure and insert into the temp table without creating it.
--no compilation error.
CREATE PROC testTemp
AS
BEGIN
INSERT INTO #tmp(dt)
SELECT GETDATE()
END

only on calling the proc does this give an execution error

View 3 Replies View Related

Power Pivot :: Temp Table Or Table Variable In Query (not Stored Procedure)?

Jul 19, 2012

I don't know if it's a local issue but I can't use temp table or table variable in a PP query (so not in a stored procedure).

Environment: W7 enterprise desktop 32 + Office 2012 32 + PowerPivot 2012 32

Simple example:
    declare @tTable(col1 int)
    insert into @tTable(col1) values (1)
    select * from @tTable

Works perfectly in SQL Server Management Studio and the database connection is OK to as I may generate PP table using complex (or simple) queries without difficulty.

But when trying to get this same result in a PP table I get an error, idem when replacing table variable by a temporary table.

Message: OLE DB or ODBC error. .... The current operation was cancelled because another operation the the transaction failed.

View 11 Replies View Related

INSERT INTO - Data Is Not Inserted - Using #temp Table To Populate Actual Table

Jul 20, 2005

Hi thereApplication : Access v2K/SQL 2KJest : Using sproc to append records into SQL tableJest sproc :1.Can have more than 1 record - so using ';' to separate each linefrom each other.2.Example of data'HARLEY.I',03004,'A000-AA00',2003-08-29,0,0,7.5,7.5,7.5,7.5,7.0,'Notes','General',1,2,3 ;'HARLEY.I',03004,'A000-AA00',2003-08-29,0,0,7.5,7.5,7.5,7.5,7.0,'Notes','General',1,2,3 ;3.Problem - gets to lineBEGIN TRAN <---------- skipsrestINSERT INTO timesheet.dbo.table14.Checked permissions for table + sproc - okWhat am I doing wrong ?Any comments most helpful......CREATE PROCEDURE [dbo].[procTimesheetInsert_Testing](@TimesheetDetails varchar(5000) = NULL,@RetCode int = NULL OUTPUT,@RetMsg varchar(100) = NULL OUTPUT,@TimesheetID int = NULL OUTPUT)WITH RECOMPILEASSET NOCOUNT ONDECLARE @SQLBase varchar(8000), @SQLBase1 varchar(8000)DECLARE @SQLComplete varchar(8000) ,@SQLComplete1 varchar(8000)DECLARE @TimesheetCount int, @TimesheetCount1 intDECLARE @TS_LastEdit smalldatetimeDECLARE @Last_Editby smalldatetimeDECLARE @User_Confirm bitDECLARE @User_Confirm_Date smalldatetimeDECLARE @DetailCount intDECLARE @Error int/* Validate input parameters. Assume success. */SELECT @RetCode = 1, @RetMsg = ''IF @TimesheetDetails IS NULLSELECT @RetCode = 0,@RetMsg = @RetMsg +'Timesheet line item(s) required.' + CHAR(13) + CHAR(10)/* Create a temp table parse out each Timesheet detail from inputparameter string,count number of detail records and create SQL statement toinsert detail records into the temp table. */CREATE TABLE #tmpTimesheetDetails(RE_Code varchar(50),PR_Code varchar(50),AC_Code varchar(50),WE_Date smalldatetime,SAT REAL DEFAULT 0,SUN REAL DEFAULT 0,MON REAL DEFAULT 0,TUE REAL DEFAULT 0,WED REAL DEFAULT 0,THU REAL DEFAULT 0,FRI REAL DEFAULT 0,Notes varchar(255),General varchar(50),PO_Number REAL,WWL_Number REAL,CN_Number REAL)SELECT @SQLBase ='INSERT INTO#tmpTimesheetDetails(RE_Code,PR_Code,AC_Code,WE_Da te,SAT,SUN,MON,TUE,WED,THU,FRI,Notes,General,PO_Nu mber,WWL_Number,CN_Number)VALUES ( 'SELECT @TimesheetCount=0WHILE LEN( @TimesheetDetails) > 1BEGINSELECT @SQLComplete = @SQLBase + LEFT( @TimesheetDetails,Charindex(';', @TimesheetDetails) -1) + ')'EXEC(@SQLComplete)SELECT @TimesheetCount = @TimesheetCount + 1SELECT @TimesheetDetails = RIGHT( @TimesheetDetails, Len(@TimesheetDetails)-Charindex(';', @TimesheetDetails))ENDIF (SELECT Count(*) FROM #tmpTimesheetDetails) <> @TimesheetCountSELECT @RetCode = 0, @RetMsg = @RetMsg + 'Timesheet Detailscouldn''t be saved.' + CHAR(13) + CHAR(10)-- If validation failed, exit procIF @RetCode = 0RETURN-- If validation ok, continueSELECT @RetMsg = @RetMsg + 'Timesheet Details ok.' + CHAR(13) +CHAR(10)/* RETURN*/-- Start transaction by inserting into Timesheet tableBEGIN TRANINSERT INTO timesheet.dbo.table1select RE_Code,PR_Code,AC_Code,WE_Date,SAT,SUN,MON,TUE,WE D,THU,FRI,Notes,General,PO_Number,WWL_Number,CN_Nu mberFROM #tmpTimesheetDetails-- Check if insert succeeded. If so, get ID.IF @@ROWCOUNT = 1SELECT @TimesheetID = @@IDENTITYELSESELECT @TimesheetID = 0,@RetCode = 0,@RetMsg = 'Insertion of new Timesheet failed.'-- If order is not inserted, rollback and exitIF @RetCode = 0BEGINROLLBACK TRAN-- RETURNEND--RETURNSELECT @Error =@@errorprint ''print "The value of @error is " + convert (varchar, @error)returnGO

View 2 Replies View Related

SQL Tools :: Adding Column To A Table Causes Copying Data Into Temp Table

Sep 23, 2015

If on the source I have a new column, the script generated by SqlPackage.exe recreates the table on the background with moving the data into a temp storage. If the table is big, such approach can cause issues.

Example of the script is below: in the source project I added columns [MyColumn_LINE_1]  and [MyColumn_LINE_5].

Is there any way I can make it generating an alter statement instead?

BEGIN TRANSACTION;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET XACT_ABORT ON;
CREATE TABLE [dbo].[tmp_ms_xx_MyTable] (
[MyColumn_TYPE_CODE] CHAR (3) NOT NULL,

[Code] ....

The same script is generated regardless the table having data or not, having a clustered or nonclustered PK.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved