I Need Help With The Following (SQL Team Cross Post)
Apr 13, 2004
I am trying to setup a shape, shape attributes and calculate the cross
sectional area using the formula specified in the tbShapes.Formula field.
See the code below.
What this does is convert the formula
(Width * Flange) + (((Height - Flange) * Leg) * Count)
to
(108 * 4) + (((36 - 4) * 5) *2)
Now I need to calculate the expression above, but the
expression is a varchar string.
Any help?
USE NORTHWIND
GO
SET NOCOUNT ON
CREATE TABLE [dbo].[tbProductCodes] (
[ProductCode] [int] NOT NULL ,
[fkAccountID] [int] NOT NULL ,
[Product] [varchar] (50) NOT NULL ,
[fkShapeID] [int] NOT NULL
) ON [PRIMARY]
GO
INSERT INTO tbProductCodes (ProductCode, fkAccountID, Product, fkShapeID)
SELECT 2001, 1, 'New Product', 1
GO
CREATE TABLE [dbo].[tbProductTemplateAttributeValues] (
[fkTemplateID] [int] NOT NULL ,
[fkAttributeID] [int] NOT NULL ,
[AttributeValue] [float] NOT NULL
) ON [PRIMARY]
GO
INSERT INTO tbProductTemplateAttributeValues (fkTemplateID, fkAttributeID, AttributeValue)
SELECT 1, 1, 108 UNION ALL
SELECT 1, 2, 36 UNION ALL
SELECT 1, 3, 4 UNION ALL
SELECT 1, 4, 5 UNION ALL
SELECT 1, 5, 2
GO
CREATE TABLE [dbo].[tbProductTemplates] (
[TemplateID] [int] NOT NULL ,
[fkProductCode] [int] NOT NULL ,
[Template] [varchar] (50) NOT NULL ,
[fkMixID] [int] NULL
) ON [PRIMARY]
GO
INSERT INTO tbProductTemplates (TemplateID, fkProductCode, Template, fkMixID)
SELECT 1, 2001, 'ProductTemplate', 1
GO
CREATE TABLE [dbo].[tbShapeAttributes] (
[AttributeID] [int] NOT NULL ,
[fkShapeID] [int] NOT NULL ,
[Attribute] [varchar] (50) NOT NULL
) ON [PRIMARY]
GO
INSERT tbShapeAttributes (AttributeID, fkShapeID, Attribute)
SELECT 1, 1, 'Width' UNION ALL
SELECT 2, 1, 'Height' UNION ALL
SELECT 3, 1, 'Flange' UNION ALL
SELECT 4, 1, 'Leg' UNION ALL
SELECT 5, 1, 'Count'
GO
CREATE TABLE [dbo].[tbShapes] (
[ShapeID] [int] NOT NULL ,
[Shape] [varchar] (50) NOT NULL ,
[Formula] [varchar] (100) NULL
) ON [PRIMARY]
GO
INSERT INTO tbShapes (ShapeID, Shape, Formula)
SELECT 1, 'Double T', '(Width * Flange) + (((Height - Flange) * Leg) * Count)'
GO
CREATE PROCEDURE usp_shapes_GetCrossSection
@iTemplate int,
@cResult varchar (500) OUTPUT
AS
declare @cAttribute varchar(50),
@fAttribute float
-- Get the formula for the templates shape
SELECT @cResult = s.Formula
FROM tbShapes AS s INNER JOIN tbProductCodes AS pc
ON s.ShapeID = pc.fkShapeID
INNER JOIN tbProductTemplates AS pt
ON pc.ProductCode = pt.fkProductCode
WHERE pt.TemplateID = @iTemplate
SELECT @cResult AS Formula
DECLARE AttributeCursor CURSOR FOR
SELECT sa.Attribute,
av.AttributeValue
FROM tbProductTemplateAttributeValues AS av INNER JOIN tbShapeAttributes AS sa
ON av.fkAttributeID = sa.AttributeID
WHERE av.fkTemplateID = @iTemplate
OPEN AttributeCursor
FETCH NEXT FROM AttributeCursor INTO @cAttribute, @fAttribute
while(@@FETCH_STATUS = 0)
BEGIN
SELECT @cResult = REPLACE(@cResult, @cAttribute, CAST(@fAttribute AS VarChar))
FETCH NEXT FROM AttributeCursor INTO @cAttribute, @fAttribute
END
SELECT @cResult AS NewFormula
CLOSE AttributeCursor
DEALLOCATE AttributeCursor
GO
-- Test stored proc
declare @iTemplate int, @fResult float
SET @iTemplate = 1
EXECUTE usp_shapes_GetCrossSection @iTemplate, @fResult OUTPUT
SELECT @fResult AS Result
GO
drop table [dbo].[tbProductCodes]
GO
drop table [dbo].[tbProductTemplateAttributeValues]
GO
drop table [dbo].[tbProductTemplates]
GO
drop table [dbo].[tbShapeAttributes]
GO
drop table [dbo].[tbShapes]
GO
DROP PROCEDURE usp_shapes_GetCrossSection
GO
Mike B
View 3 Replies
ADVERTISEMENT
Nov 2, 2014
Team members appear twice or more if they belong to more than one team. I need to be able to show their name and main team. Team is not important at the moment but I just like to include all team members and display a team name against them.This is what I have at the moment:
SELECT SystemUser.systemuserid, FullName, TeamMembership.TeamID, TeamName
FROM Team
RIGHT OUTER JOIN TeamMembership ON Team.teamid = TeamMembership.teamid
LEFT OUTER JOIN SystemUser ON TeamMembership.systemuserid = SystemUser.systemuserid
order by FullName
View 3 Replies
View Related
Oct 22, 2007
---------------------------------------------------------------
My Original Post
I have to query n table(NLRImports) using the Distinct keyword, to retrieve a set of ID numbers. ( "Select DISTINCT id_nbr from NLRImport" ).
Now i want to use those values i retrieved, to process the records in the table(NLRImports) 1 by 1. How do i use those ID no's i retrieved as Variables or parameters for my next query?? If this makes sense?
----------------------------------------------------------------
First, thanks for the response.... now here is what im trying to do.
I created a simple application in delphi to import information to a table in MSSql2005. This is some of the resulting columns...
date | id_nbr | account_nbr | sub_account_nbr | ... etc
-------------------------------------------------------------
Now there will be several entries with the same id no but on different dates, so i take it dates would rather be my pkey.
Then i need to take one person's entries(i work on id_nbr) and go thru all the entries taking the earliest date and comparing all the other entries for that person to the first date and select all the dates more than 19 days after the first date and less than 91 days from first date and place it in a new table.
I used cursor s and while loops to kind of get it going but i know that cursors are not really recommended use but the performance implications dont bother with this particular job.
What other ways should i be using to accomplish this?
thanks, i hope this is clear...
View 1 Replies
View Related
May 19, 2008
Is it possible to group by "Team" in the following SQL Datasource?
Each row has a numbers in their respective columns and need to be added up and only one row per team is shown showing the total?
SELECT HomeTeam AS Team, 1 AS Pld, CASE WHEN HomeScore > AwayScore THEN 1 ELSE 0 END AS Won,
CASE WHEN HomeScore = AwayScore THEN 1 ELSE 0 END AS Draw, CASE WHEN HomeScore < AwayScore THEN 1 ELSE 0 END AS Lost,
HomeScore AS Scored, AwayScore AS Against, HomeScore - AwayScore AS Agg,
CASE WHEN HomeScore > AwayScore THEN 3 WHEN HomeScore = AwayScore THEN 1 ELSE 0 END AS Pts
FROM tblFixtures
WHERE (CompID = 1) AND (HomeScore IS NOT NULL)
UNION ALL
SELECT AwayTeam AS Team, 1 AS Pld, CASE WHEN HomeScore < AwayScore THEN 1 ELSE 0 END AS Won,
CASE WHEN HomeScore = AwayScore THEN 1 ELSE 0 END AS Draw, CASE WHEN HomeScore > AwayScore THEN 1 ELSE 0 END AS Lost,
AwayScore AS Scored, HomeScore AS Against, AwayScore - HomeScore AS Agg,
CASE WHEN HomeScore < AwayScore THEN 3 WHEN HomeScore = AwayScore THEN 1 ELSE 0 END AS Pts
FROM tblFixtures AS tblFixtures_1
WHERE (CompID = 1) AND (HomeScore IS NOT NULL)
View 1 Replies
View Related
Dec 16, 2005
Hi, Just a quick note for all that the SSIS team has started to post fresh content for download.
We will be adding some links to various pages so you can easily see things when looking at the the SSIS portal on MSDN http://msdn.microsoft.com/SQL/bi/integration/default.aspx
For now if you search for "ssis" on the microsoft downloads site you will find the current content. Sample Logging reports, jump start training, Meta Data info, and sample components. More coming over the next few weeks...
http://www.microsoft.com/downloads/search.aspx?displaylang=en
Thank you and I hope everyone enjoys winding down 2005, or blowing it out, depending on your likes :)
SSIS team
View 1 Replies
View Related
May 15, 2006
In the past I wrote DTS transforms entirely by myself. With SSIS, our team of several developers now wants each member to develop a piece of the same package.
Do SSIS packages support this type of simultaneous multi-developer creation or is it a "one developer at a time" type product?
TIA,
Barkingdog
View 1 Replies
View Related
Jul 23, 2005
This may not be a MSSQL-specific question, butI wanted to ask it here first, in case there'sa MSSQL and/or SourceSafe solution that will help.Our dev team is having some difficulty withkeeping the nightly builds in sync with thestored proc mods. I'm wondering if there aresome good case studies on how to avoid this"drift". Something like genning a new DB fromchecked-in SPs, etc. alongside each regular build,then always have a paired enterprise app/databaseduo that is tagged and added to a history.FWIW, we have a 3-tier .NET/C# app, andADO.NET is throwing exceptions every otherday.If the suggestion is to whip the DB guys, thatworks for me as well. ;-)Nah, there's much love there.Thanks in advance,~swooz
View 2 Replies
View Related
Jul 20, 2005
i am a beginner of database design, could anyone please help me tofigure out how to make these two tables work.1) a "players" table, with columns "name", "age"2) a "teams" table, which can have one OR two player(s)a team also has a column "level", which may have values "A", "B",or "C"how do you build the "teams" table (the critical question is "do ineed to create two fields" for the maximum two possible players?")how do you use one query to display the information with the followingcolumns:"name", "age", "levelA", "levelB", "levelC" (the later three columnsare integer type, showing how many teams with coresponding level thisplayer is in).now suppose i don't have any access to sql server, i save the datainto xml, and load it into a dataset. how could you do the selectionwithin the dataset? or ahead of that, how do you specify the relationsbetween "players" and "teams".the following is the schema file i am trying to make (I still don'tknow if i need to specified the primary key... and how to buildrelation between them):<code><?xml version="1.0" ?><xs:schema id="AllTables" xmlns=""xmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="AllTables" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="Players"><xs:complexType><xs:sequence><xs:element name="PlayerID" msdata:AutoIncrement="true"type="xs:int" minOccurs="0" /><xs:element name="Name" type="xs:string" minOccurs="0" /><xs:element name="Age" type="xs:int" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="Teams"><xs:complexType><xs:sequence><xs:element name="TeamID" msdata:AutoIncrement="true"type="xs:int" minOccurs="0" /><xs:element name="Level" type="xs:string" minOccurs="0" /><xs:element name="Player1" type="xs:int" minOccurs="0" /><xs:element name="Player2" type="xs:int" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema></code>
View 2 Replies
View Related
Mar 6, 2007
I have installed SP2 on my report server and configured for Sharepoint access.
This is all ok.
I am able to use the webpart to create a report view but it wants the report. Is there a way to manage the report server (they way I did with reportmanager) in sharepoint. If so I have not found out how.
any ideas or links to show how I can have teh reports listed in Sharepoint?
Thanks
View 1 Replies
View Related
Jun 22, 2006
I would like to setup SSIS project so that multiple developers can work on same project. I am having issues with protectionlevel properties while another developer opens the package created by other developer.
Can anyone guide me on setting up project so that multiple developers could open the package and run (not simaltaneously though). Also tips on setting up source safe or team foundation will be appreciated!
Thanks
Mahesh
View 3 Replies
View Related
Dec 14, 2006
First let me say, I play to try and write up something more formal with some details of my recent frustrations of moving my SSIS packages into Team Foundation Server, I'm curious though if I'm the only one doing this.
Its seems that TFS is severely lacking some functionality to make it truly useful for SSIS. First and foremost the lack of it's ability to have an offline working mode and its inability to merge DTSX files (coupled with the fact there is no "Check-out but keep local copy" ability)
Has any one else been using TFS and SSIS, are you finding it to be adequate? I'm hoping to find out where the major issues are so we can bring it to the attention of MS for some updates. I fear this combination might not be extensively used and as a result support will be overlooked by MS in upcoming service packs.
-Dan
View 1 Replies
View Related
Feb 19, 2007
Hi,
At the moment I am working on an asp.net 2.0 application where we use sql server 2005 as database server. We are building this web application with 5 developers in paralel and we noticed that when one developer is debugging the application (hanging in a breakpoint), other developers get a sql time-out exception.
Yes we are using Transactions (System.Transactions namespace) but we have totally no idea why this side-effect is occuring.
Any suggestions or tip is more than welcome !
Grtz
View 3 Replies
View Related
Apr 3, 2006
Can someone give some comments on which program to use with SSIS ?
View 2 Replies
View Related
Nov 25, 2007
I'm working in a team, and need to share a database between the group - we don't have the luxury of sharing a server and connecting to it.
So What we'd like to do is make a copy of the database schema, and then share that through our repository.
I figured I just need to copy the .mdf file from the sql server database folder, and put it in the visual studio directory to work on it?
So I've tried this, but when I try to create a TableAdapter to the database through visual studio, It gives me an "access denied". I figure this is probably something to do with security settings?
Do you think I'll need to change my Database connection from windows authentication to sql authentication?
I don't really know exactly how to do what I'm trying to do, so any help will be appreciated.
View 1 Replies
View Related
Mar 28, 2007
Question is in the subject.
The reason I'm asking is because I want a workaround to a problem that a guy is having here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1404349&SiteID=1
-Jamie
View 1 Replies
View Related
Jul 16, 2015
Power Pivot .... Â I have a model established that has a date table, Order table, Sales rep table, and a financials table that all feed each other nicely. Â
The issue is that some of the individual sales reps are also on sales "Teams" of 2-4 people, and I am not sure how to account for that when I am building pivot tables without relying on slicers and CTRL clicking. Â
I also don't want to resort to programmatically duplicating rows via SQL.
View 5 Replies
View Related
Aug 14, 2007
Is there any web sit or weblog for contacting SQL Serve Database Engine Team?
View 4 Replies
View Related
Mar 10, 2015
I need to send email to the team when the job run completes.
On that server we have two instances one is default (2008R2) and another is 2014 From 2008r2 it will send email to the team.
I tried the profile account using anonymous and enter my company email & password but still the status is showing failed.
I do have smtp account details, I use the same port number but still failing?
View 1 Replies
View Related
May 30, 2006
We have a large number of SPs in our databases and decided it was time to get some source control. I have VSTS team explorer installed and working in visual studio, but I cannot get the plugin for SSMS to work - it just says none in the current source control plug-in dialogue box - nothing when I drop it down either.
Any ideas what I am doing wrong?
View 1 Replies
View Related
Apr 23, 2008
Hi Team Expert,
I am working on an ASP.NET and c# project. I am creating a page that allow user to add new Workitem to TFS and successfully do so. Now I would like to implement the way to email to notify the user that the new WI is added €¦. Does anyone know how to do this or have an example of how to implement that.
Any help would be greatly appreciated.
Thanks so much
Ddee
View 1 Replies
View Related
Jun 11, 2015
How to integrate current artifacts with TFS ?
For example : We have multiple applications X, Y, Z  each has  its own SSIS solution , SQL Script, MSTR report and documentation.
We move code from Dev to Test and then to PROD
How to structure the folders which will be easy to manage and easy to release ?
View 3 Replies
View Related
Dec 27, 2006
Live Webcast tomorrow
Essential Team System for Database Developers
1 PM Central time 12/28
https://www.clicktoattend.com/invitation.aspx?code=112602
View 2 Replies
View Related
May 28, 2015
I am using excel 2010 and SQL server as a data source. When I create a report with the User name "demo_user" which has db_writer access, and mail it to the colleague , he could not refresh the data with the "demo_user" credentials and apparently its throwing user name or password invalid. The one who created only could be able to refresh the data.
What should I do If other people want to refresh the data? How could I fix this issue? We are using SQL server 2012 and excel 2010 powerpivot.Â
View 2 Replies
View Related
May 25, 2006
Alright so here is what I am trying to do.
I have a form that someone fills out it has a text box as title, and a drop down box that is a category, and then a text area that is for their explanation.
On the back end I am using a stored procedure called sp_store_bkm. When I execute this it works just fine and puts the data that I put in it into the to table below is the Stored procedure code:
ALTER PROCEDURE sp_store_bkm @oID nvarchar OUTPUT, @oTitle nvarchar(50), @oCategory nvarchar(50), @obkmtext nvarchar(MAX)
AS BEGIN INSERT INTO tbl_bkms(Title, Category, bkmtext) VALUES(@oTitle, @oCategory, @obkmtext)Set @oID= SCOPE_IDENTITY() END
Now on my front end it comes up with an error in the lower left (erros on page). When I click on the error for details it seems like it is coming fromt he connection string. I cant find anything wrong with the connection string. Below is my code for the aspx page.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script>
function Submit2_onclick() {
Dim Connection As SqlConnection = "server=localhost;Database=BKM.mdf;integrated security=SSPI;" connection.Open() Try Dim command As SqlCommand = New SqlCommand("sp_store_bkm", connection) command.CommandType = CommandType.StoredProcedure Dim oID As New SqlParameter("@oID", SqlDbType.Int) oID.Direction = ParameterDirection.Output command.Parameters.Add(oID) command.Parameters.Add("@oTitle", title.text) command.Parameters.Add("@oCategory", category.text) command.Parameters.Add("@obkmtext", bkmtext.text) command.ExecuteNonQuery() Dim sOrderID As String = oID.Value }</script>
<form method="post"> <table cellpadding="10" style="width: 100%"> <tr> <td style="width: 100px"> <span style="font-size: 10pt; font-family: Verdana"> Login ID: <br /> </span> <asp:LoginName ID="LoginName1" runat="server" Font-Names="Verdana" Font-Size="10pt" ForeColor="Red" /> <span style="font-size: 10pt; font-family: Verdana"> <br /> <br /> Title:<br /> </span> <input id="title" style="width: 374px" type="text" /><br /> <br /> <span style="font-size: 10pt; font-family: Verdana"> Category:<br /> </span> <select id="Category" name="D1" size="1" language="javascript" onclick="return Select1_onclick()"> <option selected="selected">Office Applications</option> <option>VPN</option> <option>WLAN</option> </select> <br /> <span style="font-size: 10pt; font-family: Verdana"> <br /> Your BKM<br /> </span> <textarea id="bkmtext" style="width: 378px; height: 196px"></textarea><br /> <br /> <input id="Reset1" type="reset" value="reset" /> <input id="Submit2" type="submit" value="submit" language="javascript" onclick="return Submit2_onclick()" /></td> </tr> </table> </form></asp:Content>
Please help.
View 3 Replies
View Related
Jul 12, 2001
Can you help me? I'm pointing on the thread just below this post (along with the other messages on the message board).
View 1 Replies
View Related
Nov 7, 2007
Greetings friends:
I am a student at DePaul University in Chicago, IL. We have a big db project tomorrow and I'm proud with the work I've done so far, I've designed my own db and tested it using queries and such. Pretty good for being introduced to SQL just a couple short months ago. Anyway, I've sort of run into a wall here. I need to have an attribute of a table be computed from others.
I'm working with 2005 Server Management Studio and I have found the computed column specification under the column properties tab. I know that I have to enter a formula, but I'm just not sure on what to do. I have a CHG_HOUR attribute in a table called "EXPERTISE" which signifies how much a consultant charges per hour, based on what he exactly does. I also have a JOB_HOURS attribute in a JOB table (that links my CONTRACT table to CONSULTANT). I want to basically give a formula that multiplies the CHG_HOUR from the EXPERTISE table by the JOB_HOURS in the JOB table. Any suggestions on how I might do this?
Thank you in advance for your response, and hopefully with more practice and courses, I can be the one helping people like me on these boards in a few years.
View 2 Replies
View Related
Jul 20, 2005
Just testing out this posting thing... Thanks!!Join Bytes!----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups---= East/West-Coast Server Farms - Total Privacy via Encryption =---
View 2 Replies
View Related
Mar 8, 2007
I have a question about the post SP2 GDR that just came out in the last day or two. My laptop only has the client tools installed, not the server components (except for the SSIS server component). Is there any need for me to install this GDR? Does it impact the Management Studio code which views maintenance plans on remote SQL Servers or anything?
View 3 Replies
View Related
Apr 27, 2007
I am developing an application using Visual Web Designer (language VB) with a SQL Server 2000 back end.
Within my logic I have a point where I want to say "Run SQL procedure GEDFinish". GEDFinish can take several minutes, and I don't need to wait for it's results - it would be fine if it ran overnight. I can easily check whether GEDFinish has run from the database, in situation where my application logic needs to know if it has already run.
Currently I only know how to run a procedure under the direct control of my web program, but with GEDFinish this fails due to timeouts. (This will be worse in the production site). What I really want to do is to have my web program submit "Exec GEDFinish" to the SQL agent, and then forget about it. It would be even better if I could build a script for the SQL agent, for example "EXEC GEDFinish Parameter=7"
Help! How do I do this?
Thanks, Robert Barnes
View 6 Replies
View Related
Mar 1, 2002
Sorry it is my second posting , I am trying to find answer to my problem
Hello everybody.
I have problem with mail
I have 3 servers
A) SQL2000 sp2 Standard edition 1024 MB memory
B) SQL2000 sp2 Standard edition 3072 MB memory
C) SQL2000 sp2 Enterprise edition 2048 MB memory
All servers use same mail profile and they all run under same account MYDomainsvcSql2000 for server and agent and connected to same mail server
1. server C run fine
2. servers A and B could stop mail service during the day and the only way to restart it is to open EM and retype password for Sql server account (it will force Server and agent restart)
Any idea ?
View 1 Replies
View Related
Apr 7, 2004
it's been too long since I answer something on indexes and it shouldn't, indexes are a important part of SQL
View 3 Replies
View Related
Jun 21, 2004
Hi,
Is it possible to write a stored procedure which can post an XML file to a server using HTTP?
Thanks!
View 6 Replies
View Related
Aug 21, 2007
Can anyone help me to get the hotfix SQL Server 2000 build 8.00.2215 ?
As i do not find any download link.
View 3 Replies
View Related