Showing posts with label instead. Show all posts
Showing posts with label instead. Show all posts

Tuesday, March 27, 2012

Basic Insted Of Insert Trigger

I am using SQL 2005.
Could you please give me the most basic Instead Of Insert Trigger for
updating a view composed of two Tables. F0r example:
ProductTable Columns are ProductID (int, key) ProductName (varchar)
ProductAttribute Columns are Attribute1, Attribute2, ProductID.
The View is ViewProductTableProductAttribute :
SELECT dbo.ProductTable.ProductID, dbo.ProductTable.ProductName,
dbo.ProductAttribute.ProductAttribute1,
dbo.ProductAttribute.ProductAttribute2
FROM dbo.ProductTable INNER JOIN
dbo.ProductAttribute ON dbo.ProductTable.ProductID =
dbo.ProductAttribute.ProductID
How would a basic Instead Of Insert trigger work here on the View?
Would I need another view to update data to the two tables?
TIA,
PaoloPaul (PaulContactMe@.TheCornerStore.com) writes:
> I am using SQL 2005.
> Could you please give me the most basic Instead Of Insert Trigger for
> updating a view composed of two Tables. F0r example:
> ProductTable Columns are ProductID (int, key) ProductName (varchar)
> ProductAttribute Columns are Attribute1, Attribute2, ProductID.
> The View is ViewProductTableProductAttribute :
> SELECT dbo.ProductTable.ProductID, dbo.ProductTable.ProductName,
> dbo.ProductAttribute.ProductAttribute1,
> dbo.ProductAttribute.ProductAttribute2
> FROM dbo.ProductTable INNER JOIN
> dbo.ProductAttribute ON dbo.ProductTable.ProductID =
> dbo.ProductAttribute.ProductID
> How would a basic Instead Of Insert trigger work here on the View?
Are you asking us to write the requirement spec for you?
Seriously, you know the tables and the business rules. You may not
the syntax, but you know what you want to happen when you say:
INSERT view (...)
SELECT ...
So give us the CREATE TABLE, some sample data (more than one row!)
and the desired result. And some short description in text of what
you want to happen.

> Would I need another view to update data to the two tables?
A somewhat funny question. That makes me ask, why did you add a
view in the first place? I see little reason to create a second
view for the UPDATE. Then again, I don't know the busines rules.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Actually, I am experimenting. I think this is a technology, and am
curious about how it works.
Thanks,
Paul
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97F23FEBA187Yazorman@.127.0.0.1...
> Paul (PaulContactMe@.TheCornerStore.com) writes:
> Are you asking us to write the requirement spec for you?
> Seriously, you know the tables and the business rules. You may not
> the syntax, but you know what you want to happen when you say:
> INSERT view (...)
> SELECT ...
> So give us the CREATE TABLE, some sample data (more than one row!)
> and the desired result. And some short description in text of what
> you want to happen.
>
> A somewhat funny question. That makes me ask, why did you add a
> view in the first place? I see little reason to create a second
> view for the UPDATE. Then again, I don't know the busines rules.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx

Thursday, March 22, 2012

Bar Chart Help

I would like to display the series field at the start of a bar instead of
using a legend.
thanks in advanceI'm not sure I understand the question correctly. A chart of type "bar" is
actually drawn with horizontal bars and the labels of the categories are
shown as text along the y-axis. Isn't that exactly what you are looking for?
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tango" <Tango@.discussions.microsoft.com> wrote in message
news:7D560240-EF6A-4568-91E4-A3A8EB4CE0A3@.microsoft.com...
> I would like to display the series field at the start of a bar instead of
> using a legend.
> thanks in advance|||id like to have no y axis shown 9due to space limitations) but the name from
the y axis at the left hand side in the bar itself. Hope this makes sense.
"Robert Bruckner [MSFT]" wrote:
> I'm not sure I understand the question correctly. A chart of type "bar" is
> actually drawn with horizontal bars and the labels of the categories are
> shown as text along the y-axis. Isn't that exactly what you are looking for?
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Tango" <Tango@.discussions.microsoft.com> wrote in message
> news:7D560240-EF6A-4568-91E4-A3A8EB4CE0A3@.microsoft.com...
> > I would like to display the series field at the start of a bar instead of
> > using a legend.
> >
> > thanks in advance
>
>|||You could set the category label expressions to a blank: =" "
Then, use datapoint labels to show descriptions on the datapoint bars inside
the chart.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tango" <Tango@.discussions.microsoft.com> wrote in message
news:06EE7101-A06C-457C-B615-41FD45E7563F@.microsoft.com...
> id like to have no y axis shown 9due to space limitations) but the name
from
> the y axis at the left hand side in the bar itself. Hope this makes sense.
> "Robert Bruckner [MSFT]" wrote:
> > I'm not sure I understand the question correctly. A chart of type "bar"
is
> > actually drawn with horizontal bars and the labels of the categories are
> > shown as text along the y-axis. Isn't that exactly what you are looking
for?
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> >
> >
> > "Tango" <Tango@.discussions.microsoft.com> wrote in message
> > news:7D560240-EF6A-4568-91E4-A3A8EB4CE0A3@.microsoft.com...
> > > I would like to display the series field at the start of a bar instead
of
> > > using a legend.
> > >
> > > thanks in advance
> >
> >
> >|||Thanks Robert,
i cant work out how to use a datapoint label.
"Robert Bruckner [MSFT]" wrote:
> You could set the category label expressions to a blank: =" "
> Then, use datapoint labels to show descriptions on the datapoint bars inside
> the chart.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Tango" <Tango@.discussions.microsoft.com> wrote in message
> news:06EE7101-A06C-457C-B615-41FD45E7563F@.microsoft.com...
> > id like to have no y axis shown 9due to space limitations) but the name
> from
> > the y axis at the left hand side in the bar itself. Hope this makes sense.
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> > > I'm not sure I understand the question correctly. A chart of type "bar"
> is
> > > actually drawn with horizontal bars and the labels of the categories are
> > > shown as text along the y-axis. Isn't that exactly what you are looking
> for?
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > >
> > >
> > > "Tango" <Tango@.discussions.microsoft.com> wrote in message
> > > news:7D560240-EF6A-4568-91E4-A3A8EB4CE0A3@.microsoft.com...
> > > > I would like to display the series field at the start of a bar instead
> of
> > > > using a legend.
> > > >
> > > > thanks in advance
> > >
> > >
> > >
>
>|||You will find a sample report at the bottom of this posting.
In particular investigate
* the category grouping label expression
* the datapoint label expression of the "UnitsInStock" series
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tango" <Tango@.discussions.microsoft.com> wrote in message
news:04DAD287-5566-487C-903B-4F5DD719DF21@.microsoft.com...
> Thanks Robert,
> i cant work out how to use a datapoint label.
>
> "Robert Bruckner [MSFT]" wrote:
> > You could set the category label expressions to a blank: =" "
> > Then, use datapoint labels to show descriptions on the datapoint bars
inside
> > the chart.
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> >
> >
> > "Tango" <Tango@.discussions.microsoft.com> wrote in message
> > news:06EE7101-A06C-457C-B615-41FD45E7563F@.microsoft.com...
> > > id like to have no y axis shown 9due to space limitations) but the
name
> > from
> > > the y axis at the left hand side in the bar itself. Hope this makes
sense.
> > >
> > > "Robert Bruckner [MSFT]" wrote:
> > >
> > > > I'm not sure I understand the question correctly. A chart of type
"bar"
> > is
> > > > actually drawn with horizontal bars and the labels of the categories
are
> > > > shown as text along the y-axis. Isn't that exactly what you are
looking
> > for?
> > > >
> > > > --
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> > > >
> > > >
> > > > "Tango" <Tango@.discussions.microsoft.com> wrote in message
> > > > news:7D560240-EF6A-4568-91E4-A3A8EB4CE0A3@.microsoft.com...
> > > > > I would like to display the series field at the start of a bar
instead
> > of
> > > > > using a legend.
> > > > >
> > > > > thanks in advance
> > > >
=========================================================
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
tion"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<RightMargin>1in</RightMargin>
<Body>
<ReportItems>
<Chart Name="chart1">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>BottomCenter</Position>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel>
<Value>=First(Fields!ProductName.Value)</Value>
<Visible>true</Visible>
</DataLabel>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsOnOrder.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Marker />
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Visible>true</Visible>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>1in</Top>
<Title />
<Width>5.5in</Width>
<CategoryGroupings>
<CategoryGrouping>
<DynamicCategories>
<Grouping Name="chart1_CategoryGroup1">
<GroupExpressions>
<GroupExpression>=Fields!ProductName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Label>=" "</Label>
</DynamicCategories>
</CategoryGrouping>
</CategoryGroupings>
<Height>3in</Height>
<SeriesGroupings>
<SeriesGrouping>
<StaticSeries>
<StaticMember>
<Label>Units In Stock</Label>
</StaticMember>
<StaticMember>
<Label>Units On Order</Label>
</StaticMember>
</StaticSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Left>0.625in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
</ReportItems>
<Style />
<Height>4.5in</Height>
</Body>
<TopMargin>1in</TopMargin>
<DataSources>
<DataSource Name="Northwind">
<rd:DataSourceID>f6248fbe-a9a8-40b9-8084-1f56b066026d</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=.;initial
catalog=Northwind</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<Width>6.5in</Width>
<DataSets>
<DataSet Name="DataSet1">
<Fields>
<Field Name="ProductID">
<DataField>ProductID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="ProductName">
<DataField>ProductName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="SupplierID">
<DataField>SupplierID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="CategoryID">
<DataField>CategoryID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="QuantityPerUnit">
<DataField>QuantityPerUnit</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UnitPrice">
<DataField>UnitPrice</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="UnitsInStock">
<DataField>UnitsInStock</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="UnitsOnOrder">
<DataField>UnitsOnOrder</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="ReorderLevel">
<DataField>ReorderLevel</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="Discontinued">
<DataField>Discontinued</DataField>
<rd:TypeName>System.Boolean</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>Northwind</DataSourceName>
<CommandText>select top 6 * from products</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
</DataSet>
</DataSets>
<LeftMargin>1in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>205aa2a3-8ec1-473c-a700-2270ed171aac</rd:ReportID>
<BottomMargin>1in</BottomMargin>
<Language>en-US</Language>
</Report>

Friday, February 10, 2012

Backup To Network Share

I would like to backup my databases to a network share (NAS) instead of local disk using Maintenance Plans created by Enterprise Manager. I have successfully used a UNC path to target the destination network share but have not been to figure out how to submit a logon to the network share before the backup is executed.

The SQL Server instance is running in the context of the local system account.

Can I insert a step in the SQL SQL job that is created by the Maintenance Plans that changes the Windows account that the backup runs under? If yes what command syntax would I use in the inserted step or is there another way to accomplish that I'm attempting to do?

thanks
HPTo do this you need the SQL Service to run as a network user account that has pemissions over the share.

That being said it is generally reccomended that you create your backup file locally and then copy it over the network using a DOS batch file that uses copy or some such method.