Thursday, March 29, 2012
Describe Table
What is the equivalent of Describe table of Oracle in SQL server.
I want to see the table fields for a table in SQL server any command???
TIAsp_help <tablename>
Tuesday, March 27, 2012
Derived Fields
Select employid,
Gross=( Select sum (uprtrxam) from Fleet..upr30300 where pyrlrtyp=1),
DedofWages=( Select sum (uprtrxam) from Fleet..upr30300 where
pyrltyp=2),
Gross-DedofWages
from FLEET..UPR00100
The problem is the third field (Gross-DedofWages). It says Invalid
column. Any ideas ?
Thanks, GirishIt doesn't look like your query would give the result you expected
anyway - the subqueries aren't correlated. Try this:
SELECT U.employid, T.gross, T.dedofwages,
T.gross - T.dedofwages
FROM Fleet..upr00100 AS U
LEFT JOIN
(SELECT employid,
CASE WHEN pyrlrtyp=1 THEN uprtrxam END AS gross,
CASE WHEN pyrlrtyp=2 THEN uprtrxam END AS dedofwages
FROM Fleet..upr30300
WHERE pyrlrtyp BETWEEN 1 AND 2
GROUP BY employid) AS T
ON U.empoyid = T.employeid
The rule is that columns in the SELECT list must exist in the base
tables or derived tables. Aliases aren't allowed.
--
David Portas
SQL Server MVP
--|||Oops. Correction:
SELECT U.employid, T.gross, T.dedofwages,
T.gross - T.dedofwages
FROM upr00100 AS U
LEFT JOIN
(SELECT employid,
SUM(CASE WHEN pyrlrtyp=1 THEN uprtrxam END) AS gross,
SUM(CASE WHEN pyrlrtyp=2 THEN uprtrxam END) AS dedofwages
FROM upr30300
WHERE pyrlrtyp BETWEEN 1 AND 2
GROUP BY employid) AS T
ON U.employid = T.employid
--
David Portas
SQL Server MVP
--|||Here is how a SELECT works in SQL ... at least in theory. Real
products will optimize things, but the code has to produce the same
results.
a) Start in the FROM clause and build a working table from all of the
joins, unions, intersections, and whatever other table constructors are
there. The table expression> AS <correlation name> option allows you
give a name to this working table which you then have to use for the
rest of the containing query.
b) Go to the WHERE clause and remove rows that do not pass criteria;
that is, that do not test to TRUE (i.e. reject UNKNOWN and FALSE). The
WHERE clause is applied to the working set in the FROM clause.
c) Go to the optional GROUP BY clause, make groups and reduce each
group to a single row, replacing the original working table with the
new grouped table. The rows of a grouped table must be group
characteristics: (1) a grouping column (2) a statistic about the group
(i.e. aggregate functions) (3) a function or (4) an expression made up
those three items.
d) Go to the optional HAVING clause and apply it against the grouped
working table; if there was no GROUP BY clause, treat the entire table
as one group.
e) Go to the SELECT clause and construct the expressions in the list.
This means that the scalar subqueries, function calls and expressions
in the SELECT are done after all the other clauses are done. The
"AS" operator can also give names to expressions in the SELECT
list. These new names come into existence all at once, but after the
WHERE clause, GROUP BY clause and HAVING clause has been executed; you
cannot use them in the SELECT list or the WHERE clause for that reason.
If there is a SELECT DISTINCT, then redundant duplicate rows are
removed. For purposes of defining a duplicate row, NULLs are treated
as matching (just like in the GROUP BY).
f) Nested query expressions follow the usual scoping rules you would
expect from a block structured language like C, Pascal, Algol, etc.
Namely, the innermost queries can reference columns and tables in the
queries in which they are contained.
g) The ORDER BY clause is part of a cursor, not a query. The result
set is passed to the cursor, which can only see the names in the SELECT
clause list, and the sorting is done there. The ORDER BY clause cannot
have expression in it, or references to other columns because the
result set has been converted into a sequential file structure and that
is what is being sorted.
As you can see, things happen "all at once" in SQL, not "from left to
right" as they would in a sequential file/procedural language model. In
those languages, these two statements produce different results:
READ (a, b, c) FROM File_X;
READ (c, a, b) FROM File_X;
while these two statements return the same data:
SELECT a, b, c FROM Table_X;
SELECT c, a, b FROM Table_X;
Think about what a confused mess this statement is in the SQL model.
SELECT f(c2) AS c1, f(c1) AS c2 FROM Foobar;
That is why such nonsense is illegal syntax.sql
Sunday, March 25, 2012
derived column help
Hi Guys,
How can i put in a derived column the value of 3 columns? I've tried these:
[MyId]+[Paper1]
"[MyId]+[Paper1]"
but no luck. How can i put it right?
Thanks
Gemma
The first one looks correct. [Column1] + [Column2] + [Column3]
Note: Are the three columns you are trying to combine all of the same type (i.e. unicode string, string, etc)? If not you will probably need to either convert them before trying this or cast them inside of the derived column transform.
|||Maybe you have a type mismatch or a typo?
Try type casting and then concatenating. e.g. (DT_WSTR) [MyID] + [Paper1]
The top right box in the transformation editor contains these functions, so dont sweat the syntax, and the Double Inverted commas etc.
The top left box contains available variables and columns. Dragging and dropping your columns into the expression will avoid typos.
HTH
|||Any error messages?|||Hi,
I have 3 different data type columns. One is int, 2nd one is varchar and 3rd one is datetime.
What can i do as still in the expression its coming up as red and i can't press ok.
Maybe i'm not putting in the function right.
Can someone tell me how to put them in the expression box?
Thanks
Gemma
|||Hi Guys,
Here is the error message:
TITLE: Microsoft Visual Studio
Error at GetMyData [Derived Column [548]]: The data types "DT_I4" and "DT_WSTR" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.
Error at GetMyData [Derived Column [548]]: Attempt to set the result type of binary operation "MyID + MyNo" failed with error code 0xC0047080.
Error at GetMyData [Derived Column [548]]: Computing the expression "[MyID] + [MyNo] + [Paper1]" failed with error code 0xC0047084. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.
Error at GetMyData [Derived Column [548]]: The expression "[MyID] + [MyNo] + [Paper1]" on "output column "MyNewID" (684)" is not valid.
Error at GetMyData [Derived Column [548]]: Failed to set property "Expression" on "output column "MyNewID" (684)".
ADDITIONAL INFORMATION:
Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)
Gemma
|||You must convert to string before concactenate.
Regards!!
|||Hi,
If i knew how i would have done it by now
Can you tell me how should I with the syntax?
Thanks
Gemma
|||(DT_WSTR) [MyID] + (DT_WSTR)[Paper1]|||
David Frommer wrote:
(DT_WSTR) [MyID] + (DT_WSTR)[Paper1]
The above examples by David and karfast are close, but not quite right.
(DT_WSTR,length)[MyID] + (DT_WSTR,length)[Paper1] - (where length is the number of bytes long the string is to be.)
So, for example, you could have:
(DT_WSTR,50)[MyID] + (DT_WSTR,50)[Paper1]|||
OK, try:
(DT_WSTR,2)([Column1])+(DT_WSTR,2)([Column2])+(DT_WSTR,2)([Column3])
Replace 2 for the lenght of your columns...
I hope helped!!!
|||Thanks pedro.
you're a life saver.
Gemma
Thursday, March 22, 2012
Deployment question: SQLDB - SSIS on different boxes with SQL Agent for scheduling
I am running SQL Server Integration Service(SSIS) and SQL Server Database Service (SQLDB) on different boxes. I can't have SSIS installed on SQLDB box because in my prod. environment, the DB box has *just* DB - no services or no other fancy stuff. So far so good.
Now, if I want to schedule the SSIS packages (deployed on MSDB) to run periodically, I need to create an SQL Agent job (or everyone else here is using a Windows scheduler instead?). SQL Agent has dependency on SQLDB and so it goes on the SQLDB box, correct? Can I run job steps to execute SSIS packages via remote SSIS service (on another box)? If not, I cannot separate SSIS and SQLDB on two boxes and have SQL Agent run the packages periodically, right?
What am I missing?
thanks,
Nitesh
Is there a reason you cannot install DB on the IS box? That would be best for your case as I understand it. You could also keep your packages on your IS box then as well.
To answer your question, there is no current IS feature for running packages remotely. Please see this thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=18177&SiteID=1
KirkHaselden wrote:
Is there a reason you cannot install DB on the IS box? That would be best for your case as I understand it. You could also keep your packages on your IS box then as well.
There are two reasons:
Hard Reason --> Our production environment does not allow to install *ANYTHING* on the box that runs the database (i.e. SQL DB). This was the main reason we were not using DTS.
Soft Reason --> For deployment, we would like to have separate tiers for DB, app server components (i.e. SS*S), and presentation components (SPS etc). One may argue that SSIS is a component at DB tier and its scaling, clustering etc will be dependent on the DB tier.
KirkHaselden wrote:
To answer your question, there is no current IS feature for running packages remotely. Please see this thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=18177&SiteID=1
I guess I did not put the question correctly.
What I want to know is if I can configure SQL Agent running on machineA to execute SSIS packages using the SSIS Service running on machineB. Note that machineA does not have SSIS Service running (only machineB). The packages themselves can be stored locally on machineB, if needed (but I am hopeful that it should not be an issue and msdb of machineA should work just fine).
Thanks,
Nitesh
If a process on machineA calls a package, then it will run a A, so you need IS installed on A. You can load the package from B or wherever, but the package runs on the same machine as the process which called it and hosts it. You would need a layer of abstraction, which is not currently available in IS itself, that is really remote execution.
Simplest method is to have SQLAgent on B, and call the job, since this is just saying start a job, which means the process runs on B.
|||<quote>Simplest method is to have SQLAgent on B, and call the job, since this is just saying start a job, which means the process runs on B.
</quote>
The problem with having SQLAgent on B is that I will need to have SQLDB also on B (because SQLAgent has a dependency on SQLDB). This defeats the original plan of having SQLDB on machine A and SSIS on machine B separately.|||In my opinion it is the simplest, but not the only way. You can do any form of remote call, such that the server/listener on the remote machine hosts the SSIS process.
You can use any scheduler you like, it is just that SQL Agent can easily be controlled remotely, through T-SQL which most of us are quite happy with already.
I don't see what the issue is with having another SQL instance on the SSIS machine, after all would it not be nice to have a local working store, in fact don't some tasks want a SQL store, and therefore having it locally makes much more sense. I think your network costs could get excessive, just for the sake of keeping things separate. By all means keep server A clean, and have your main data there, but what is the harm in having SQL on server B as well. You like to have separate tiers, but is it so strict you cannot mix applications, should it not be functions really, in which case where is the issue? Having a no SQL and IS on the same machine at all, regardless of the use of SQL seems rather artificial and just making life hard for the sake of it. Offloading IS onto a separate machine makes sens as well for large volumes, to reduce impact on your main production SQL server, but I woudl argue that the IS box should be the controller of the IS based processes, and not the other way around.
Saying all that remote execution would be cool to have too.|||
DarrenSQLIS wrote:
In my opinion it is the simplest, but not the only way. You can do any form of remote call, such that the server/listener on the remote machine hosts the SSIS process.
Unfortunately, my prod environment doesn't allow for the simplest solution, that I would love to have.
DarrenSQLIS wrote:
You can use any scheduler you like, it is just that SQL Agent can easily be controlled remotely, through T-SQL which most of us are quite happy with already.
I would love to use SQL Agent. Since it has a dependency on SQLDB, I cannot have it on SSIS box. If SQL Agent could invoke SSIS remotely, I would have take n that.
DarrenSQLIS wrote:
I don't see what the issue is with having another SQL instance on the SSIS machine, after all would it not be nice to have a local working store, in fact don't some tasks want a SQL store, and therefore having it locally makes much more sense.
Issue is simple - it won't be supported by our database group. Our DB group controlls all the DB instances, and they have nothing at all on those boxes which they support. So, SQLDB on SSIS box won't be supported. I don't want to get calls in the middle of the night for that and neither do I want to start doing backups, maintenance etc.
DarrenSQLIS wrote:
I think your network costs could get excessive, just for the sake of keeping things separate.
I know lot many enterprises that enforce such policy of having clean DB boxes.
I thought that network costs for such configurations will not adversely impact performance too much. Am I wrong?
DarrenSQLIS wrote:
By all means keep server A clean, and have your main data there, but what is the harm in having SQL on server B as well. You like to have separate tiers, but is it so strict you cannot mix applications, should it not be functions really, in which case where is the issue? Having a no SQL and IS on the same machine at all, regardless of the use of SQL seems rather artificial and just making life hard for the sake of it. Offloading IS onto a separate machine makes sens as well for large volumes, to reduce impact on your main production SQL server, but I woudl argue that the IS box should be the controller of the IS based processes, and not the other way around.Saying all that remote execution would be cool to have too.
Bottomline is -> It is not important what I could do to get around the issue, it is more important that the product should be deployable in a layered/tiered fashion on separate boxes with support for scheduling packages on whatever is the preferred scheduling mechanism (i.e. SQLAgent). Please understand that there exist network deployment scenarios in enterprises that might not work with having a side-kick SQLDB instance on SSIS box.
Thanks for your suggestions though.
Nitesh
|||
Nitesh Ambastha wrote:
Issue is simple - it won't be supported by our database group. Our DB group controlls all the DB instances, and they have nothing at all on those boxes which they support. So, SQLDB on SSIS box won't be supported.
Somewhat of a retorical question or point, but if your DB group does not understand SSIS then they should not allow you to use it. Your use of it could adversely impact the avilability of the pure SQL systems, I would never allow any system to interact with my SQL systems that could have such an impact unless I had sufficient understanding of it. If they did understand it, then what is the problem :) This is my personal point, so no response required, but it seems an artificial rule.
Nitesh Ambastha wrote:
I thought that network costs for such configurations will not adversely impact performance too much. Am I wrong?
I was trying to highlight the time and bandwidth costs. The further away from your data your SSIS is, the slower it will be, although you could solve some of that by spending money on faster links. So for large amounts of data processing it could have an impact since you will be running across the two machines.
Nitesh Ambastha wrote:
...for scheduling packages on whatever is the preferred scheduling mechanism (i.e. SQLAgent).
SQL Agent is my preferred scheduler, and maybe yours too, but many organisations have their own standards. Many houses use IBM/Tivoli for example, and SQLAgent is not required for SSIS. If you would prefer to use it, then yes you are stuck. I think buyng SQL Server for SQLAgent is an overkill, but if you look at that SQL Instance in the same way as you look at MSDE, then it is no big deal. There are plenty of proucts our there that install DB engines. I saw a report that said Informix (I think that was the one) was one of the most widely deployed DBs, and that is because CA shoved it under the covers of ArcServe backup, probably for the scheduling :)
Wednesday, March 21, 2012
Deployment Error with AS2005
Hey guys,
Love this forum, it has helped so much so far!!
Im new to using Analysis services, although i have experience with OLAP cubes. I have desinged my own cube and when i go to deploy it to the analysis server, i am getting the following errors: Could anyone please help me out!!! I think the errors 2-4 relate back to the first error. I have tried searching MSDN and Google, but i cannot find anything!!!
Thanks.. Scotty
Error 1 Errors in the high-level relational engine. The following exception occurred while the managed IDbConnection interface was being used: Could not load file or assembly 'System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.. 0 0
Error 2 Errors in the high-level relational engine. A connection could not be made to the data source with the DataSourceID of 'Movex', Name of 'Movex'. 0 0
Error 3 Errors in the OLAP storage engine: An error occurred while the dimension, with the ID of 'System Calendar', Name of 'System Calendar' was being processed. 0 0
Error 4 Errors in the OLAP storage engine: An error occurred while the 'Year' attribute of the 'System Calendar' dimension from the 'Gates Australia Sales Analysis' database was being processed. 0 0
What provider are you using to connect to relational database?
What is your relataional database? What version?
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Deployment Error with AS2005
Hey guys,
Love this forum, it has helped so much so far!!
Im new to using Analysis services, although i have experience with OLAP cubes. I have desinged my own cube and when i go to deploy it to the analysis server, i am getting the following errors: Could anyone please help me out!!! I think the errors 2-4 relate back to the first error. I have tried searching MSDN and Google, but i cannot find anything!!!
Thanks.. Scotty
Error 1 Errors in the high-level relational engine. The following exception occurred while the managed IDbConnection interface was being used: Could not load file or assembly 'System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.. 0 0
Error 2 Errors in the high-level relational engine. A connection could not be made to the data source with the DataSourceID of 'Movex', Name of 'Movex'. 0 0
Error 3 Errors in the OLAP storage engine: An error occurred while the dimension, with the ID of 'System Calendar', Name of 'System Calendar' was being processed. 0 0
Error 4 Errors in the OLAP storage engine: An error occurred while the 'Year' attribute of the 'System Calendar' dimension from the 'Gates Australia Sales Analysis' database was being processed. 0 0
What provider are you using to connect to relational database?
What is your relataional database? What version?
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.