Security Levels Of CLR Code When Deployed To Another Server.

Mar 29, 2006

Hi,

My question kind of covers a couple of areas.

I have written some SQL 05 CLR code that produces a single DLL file. I have specified that the code is 'Safe' e.g. it will not be carrying out any external assembly access or other file accesss.

The code simply contains some stored procedures that will update/instert etc data from the database.

The question is, how do I actually deploy the code to a a remote server? Do i simply take the DLL and use CREATE ASSEMBLY code to set it up?

Furthermore, are there any security issues i need to consider when i deploy the assembly given that I have already set up the security to be 'Safe' ? e.g. is there anyway that a database can be locked down so that CLR code would not run irrespective of the safe setting.

As far as I understand it, SQL CLR code is ran under the SQL Server service account, so does this mean that if this user is locked down the code would not run?

Any clarifications or extra info would be greatly appreciated.



Peds

View 6 Replies


ADVERTISEMENT

Where Is My .NET Code Deployed?

Nov 27, 2006

Dear folks

When I deploy an assemly into SQL Server using the Visual Studio IDE, it claims than it also deploys the source code to the server and the build process also shows deploying the files, but I can not find the files.

I am now developing on Windows XP and the SQL Server is also the Developer Edition on my PC.

Please help.

Parviz

View 3 Replies View Related

Code Access Security Across Multiple Assembly Security Extension

Oct 14, 2005

Hello there I have trying to figure out for days how to enable FullTrust for my Reporting Services security extension.

View 9 Replies View Related

Code!func To Get Values In Header Only Works In IDE And Not Deployed Report (also Worked Ok In RS2000)

Jul 18, 2007

I have code



Function GetDealCount(reportItems)

return iif(IsNothing(reportItems!txtDetailCountRows.Value), 0, reportItems!txtDetailCountRows.Value)

End Function

Function GetSumNotionalAmount(reportItems)

return iif(IsNothing(reportItems!txtDealSumNotionalAmount.Value), 0, reportItems!txtDealSumNotionalAmount.Value)

End Function



That I am calling from a textboxes in the page header

= Code.GetDealCount(ReportItems) & " Deal(s)"

also

= Parameters!BaseCurrency.Value + " " + Format(Code.GetSumNotionalAmount(ReportItems),"N2").ToString().Replace(",","'")





When I preview the report in VS.NET I get values showing.

When I deploy the report I just get #Error showing.



Also this report used to work fine in RS2000



Does anyone know the cause of this issue?

View 6 Replies View Related

Code Security When SQLSrvExp And App. Is Running On Same Pc

Dec 20, 2007

Hi,

My application is running on one machine using SQL Server Express
in Administrator user.

How can softwre-user can be restricted to edit stored procedures,functions and triggers ?
{using SQL Server Management Studio Express}

Is the better way to write CLR based procedures,functions and triggers ?

Please tell me.

Parminder

View 15 Replies View Related

Moving A Database Between Two SQL Server With Different Patch Levels

Jul 20, 2005

Hi,I need to move a database from an instance running SQL Server 2000 SP3to another running SQL Server 2000 SP2. Can I just use backup/restoreor detach/reattach and let SQL server take care of any downgrading (ifany).Many thanksGiovanni

View 4 Replies View Related

Code And Data Security In Hosted Servers

May 2, 2008

Dear guys

I want to publish my web site and sql server on a hosted server. But i'm worried about people behind the server. all of my codes including web and stored procedures of sql server are open. as far as I know, there is no effective way to protect web pages source. how about sql server? I mean compiling stored procedures.

and another important thing is data. I think certain people have potential to see or change all of my records, or for example give email address of my customers to a third party or ... .

Is there any way?

View 4 Replies View Related

Security Exception When Calling Custom Code From A Report.

Nov 13, 2006

Hello,

When I run my report from within visual studio 2005 it generates just fine.

However, when I run the report from the reporting services local web site I get the following error. What do I need to do to fix this (temporarily turning off .net security uusing caspol didn't work).


An error occurred while executing OnInit: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed





View 9 Replies View Related

SQL 2012 :: Blocking In Report Server Database And Changing Isolation Levels?

Oct 12, 2015

We are getting frequently blocking in Report server database.

Is it ok to change isolation level to RCSI for report server database?

View 1 Replies View Related

Package Hangs On Deployed Server

Nov 20, 2007

I have an SSIS package that executes in about 1:20min from Visual Studio on my local machine. While executing, my machine is somewhat unresponsive.

When I deploy the package to the database server -- the very same database server that I am accessing from my local machine -- the package executes but eventually hangs. It appears to be running out of memory, and I usually have to kill the process to get the machine to respond. While it's hanging, the machine is unresponsive to all users. The hardware (including memory) is identical between my local development box and the server.

How should I troubleshoot this? I've tried deploying the package to MSDB, file system, running from dtexec, and running from dtexecui. This is very frustrating!

Thanks for any help.

--j

View 1 Replies View Related

Deployed Application Isn't Connecting To SQL Server

Jan 30, 2007

When deploying my application that uses sql server it doesn't connect to the server.

I checked the connection string & it's ok the server instance is the same.

The computer name isn't the same & i use the .SQLExpress as the data source.

I get an error saying 'sqlserver does not allow remote connections error 26 locating server / instance specified'.

View 6 Replies View Related

Access Protection On Deployed SQL Server

Jan 30, 2007



How can we control the accesses to a SQL Server that has been deployed on customer site? Basically, we do not want user to log in the database server, even as sa, except through our application.

Any recommendation?

Thanks,

Xiaodoudou

View 3 Replies View Related

Running A Report Deployed On Reporting Server From C#

Sep 11, 2007



I have a report deployed on reporting serice. I am using reporting web service.
How can we call the report, assign parameters and execute it on a webpage

View 8 Replies View Related

Where Should The .dtsconfig File Be Deployed On Dev,Prod Server

Nov 29, 2007

I am migrating from local to Dev,QA and Prod.
I created a .dtsconfig file containing database connection strings to Dev database. What is the "location" on the Dev server where this .dtsconfig file nees to be deployed to??

Thanks for your help.

View 5 Replies View Related

Dynamic Images (RTF) Missing When Deployed To Server

Jan 10, 2008

Hi all,

Thanks for sharing your experiences here. In some cases, I've saved quite a bit of time. Unfortunately, I haven't found a solution for my current issue.

I'm using VS.NET 2005 and SQL Server 2005. My development computer is running Windows XP SP2. SQL Server 2005 database and reporting services are running on Windows 2003 Server.

My business requirement is to develop and deploy a report which takes rich text (RTF) stored in the database (datatype = TEXT) and converts it to an image at runtime using a custom assembly (source can be found here http://blogs.digineer.com/blogs/jasons/archive/2006/10/03/520.aspx). I am able to generate and view the dynamic image containing the RTF on my local (i.e., developer) computer both using the ReportManager web interface and using the Render method. When I deploy this to our test server, I end up with a broken link image.


To recap, I have taken the following steps.



Created custom assembly using VS.NET 2005 which converts RTF to bitmap image. Custom assembly has a strong name.

On local developer machine


Copied custom assembly to C:Program FilesMicrosoft Visual Studio 8Common7IDEPrivateAssemblies.

Modified C:Program FilesMicrosoft Visual Studio 8Common7IDEPrivateAssembliesRSReportDesigner.config to include a CodeGroup which grants FullTrust to custom assembly based on StrongNameMembership (NOTE: ReadMe.txt doesn't mention adding an entry to this file).

Modified C:Program FilesMicrosoft Visual Studio 8Common7IDEPrivateAssembliesRSPreviewPolicy.config to include a CodeGroup which grants FullTrust to custom assembly based on StrongNameMembership (NOTE: ReadMe.txt doesn't mention adding an entry to this file).

Modified report using VS.NET 2005 as follows


Added reference to custom assembly and System.Drawing.

Added image control with type=Database, MimeType=image/bmp, Value = call to custom assembly method; method is passed value of database field which contains RTF.

Deployed report.

Viewed report successfully both via HTML and via Render method of WebService using EXCEL as output format. HTML for image <IMG SRC="/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=ohj0pjaplbl5h255phlplz45&amp;ControlID=883e299f22ca4413b398a024cec134b2&amp;Culture=2055&amp;UICulture=7&amp;ReportStack=1&amp;OpType=ReportImage&amp;StreamID=ed4b4d3b-d54d-4043-9fea-1c06f153f9a1"/>

On local developer machine and server


Copied custom assembly to C:Program FilesMicrosoft SQL ServerMSSQL.3Reporting ServicesReportServerin

Modified C:Program FilesMicrosoft SQL ServerMSSQL.3Reporting ServicesReportServer
ssrvpolicy.config to include a CodeGroup which grants FullTrust to custom assembly based on StrongNameMembership (NOTE: source code indicates permissions should be granted based on UrlMembership).

Deployed report.

Viewed report unsuccessfully both via HTML and via Render method of WebService using EXCEL as output format. HTML for image <IMG SRC="" />
Initially, I got error messages when exporting to Excel along the lines of ,"data is missing" but these appear to have been resolved by granting permissions in .config files which we not mentioned in ReadMe.txt. I've have run out of things to try and am at my wits end. I am convinced the solution has something to do with permissions since this works on my computer but not on the server.

Thanks in advance for any thoughts or suggestions.

Regards,
Bill

View 1 Replies View Related

Package Fast In VS But Slow When Deployed To Server

Sep 20, 2007

I have a package which completes in 3 minutes when ran from Visual Studio but when deployed to SSIS (same machine) it rans for more than 2 hours. What could be the reason for this?

View 4 Replies View Related

Reports Deployed To Standard Edition RS And SQL Server

Feb 13, 2007

Hello,
We have successfully developed the reports on our testing machine with SQL Server 2000 Enterprise + Reporting Services 2000 Enterprise. Is there any problem if we deploy the reports to the production machine that runs SQL Server 2000 Standard and Reporting Services 2000 Standard?

Thanks in advance!

View 1 Replies View Related

Can't Retrieve Data Through ODBC In Assembly (dll) Deployed On Server

Jun 14, 2007

Hi,

In SSRS 2005, I have an assembly(dll) which is included in a report in order to retrieve data ( OdbcConnection) from database as special condition while the runtime of report. This assembly works FINE in the preview of VS development tools. But it is NOT working when deploying to server, it ONLY returns default value instead of database's value.



Anyone knows how to solve it ? Many Many thanks















View 2 Replies View Related

Problem With Label Printing When Deployed In Reporting Server

Dec 27, 2007



Hi Guys,

I am having a unique problem with the Reporting server. We are using SQL Server 2005 and we have a dedicated server for reports. I created a report for creating labels and it is workinf fine in my development environment (running it through Visual Studio) but goes way off while printing it from the reporting server. I wanted to check the rdl files in the server in which I deployed but could not find it. I would really appreciate if you can give me a solution by which label printing could be done without any problem in the server.

Thanks,
Raja

View 11 Replies View Related

Wrong Version Of SQL Server Mobile Deployed To Emulator?

Feb 2, 2006

I am developing a mobile application with Visual Studio 2005 RTM. I created a .SDF database from scratch within the Server Explorer window. Based on the properties of the database, this is a version 3.0 DB. I then deploy the application to the Pocket PC 2003 SE Emulator and I receive an error when trying to open the database from my app. It's a very generic error:

System.SData.SqlServerCE.SqlCEException

I trap the error in my code, but there is no message in the exception object.

If I try to open it with Query Analyzer on the device, I get an error stating "The file is not a valid database file". It appears that SQL CE 2.0 was deployed to the emulator.

I noticed that when I add a reference in my project to the System.Data.SQLServerCE namespace, it defaults to this DLL:

C:Program FilesMicrosoft Visual Studio 8SmartDevicesSDKSQL ServerMobilev2.0System.Data.SqlServerCe.dll

I tried removing that and manually adding a reference by browsing to this 3.0 DLL:

C:Program FilesMicrosoft Visual Studio 8SmartDevicesSDKSQL ServerMobilev3.0System.Data.SqlServerCe.dll

I then receive the following build error:

Unable to load referenced library 'C:Program FilesMicrosoft Visual Studio 8SmartDevicesSDKSQL ServerMobilev3.0System.Data.SqlServerCe.dll': Version 2.0 is not a compatible version.

If I build the database in my application from scratch from within my code, everything works fine, which I believe is because it is a 2.0 database that is generated.

To make a long story short:

How do I get my project to reference the 3.0 SQL Server CE namespace and deploy it to the emulator?

View 1 Replies View Related

Autofill Date Parameters Do Not Work When Deployed To Server

Jun 14, 2007

Good morning all,



I have a report which measures supplier performance for the previous month. It takes an age to generate so I am trying to cache a copy to a null location first thing in the morning to speed up the process. The problem I'm having is in getting the report to select the first day and last day of the month for the two parameters that the report needs to run.



In BIDS the report runs perfectly when previewed, however, when it is deployed to the report server I get the following error: 'Error during processing of €˜RP2€™ report parameter. (rsReportParameterProcessingError)'



I have used the following two statements for the default values of the parameters, which work in BIDS, so I can't understand why they don't when it's deployed. I'm also sure there is an easier way of doing this, but after about an hour searching yesterday and not finding anything it only took me about half that time to use these statements:



for opening date:



=IIf(Month(Now()) = 1, CDate("01/12/" & CInt(Year(Now())-1)), IIf(Month(Now()) = 2, CDate("01/01/" & Year(Now())), IIf(Month(Now()) = 3, CDate("01/02/" & Year(Now())), IIf(Month(NOw()) = 4, CDate("01/03/" & Year(Now())), IIf(Month(Now()) = 5, CDate("01/04/" & Year(Now())), IIf(Month(Now()) = 6, CDate("01/05/" & Year(Now())), IIf(Month(Now()) = 7, CDate("01/06/" & Year(Now())), IIf(Month(Now()) = 8, CDate("01/07/" & Year(Now())), IIf(Month(Now()) = 9, CDate("01/08/" & Year(Now())), IIf(Month(Now()) = 10, CDate("01/09/" & Year(Now())), IIf(Month(Now()) = 11, Cdate("01/10/" & Year(Now())), IIf(Month(Now()) = 12, CDate("01/11/" & Year(Now())), CDate("01/12/1900")))))))))))))



for closing date (pretty similar really, this is the parameter with which the report server finds an error):



=IIf(Month(Now()) = 1, CDate("31/12/" & CInt(Year(Now())-1)), IIf(Month(Now()) = 2, CDate("31/01/" & Year(Now())), IIf(Month(Now()) = 3, CDate("28/02/" & Year(Now())), IIf(Month(Now()) = 4, CDate("31/03/" & Year(Now())), IIf(Month(Now()) = 5, CDate("30/04/" & Year(Now())), IIf(Month(Now()) = 6, CDate("31/05/" & Year(Now())), IIf(Month(Now()) = 7, CDate("30/06/" & Year(Now())), IIf(Month(Now()) = 8, CDate("31/07/" & Year(Now())), IIf(Month(Now()) = 9, CDate("31/08/" & Year(Now())), IIf(Month(Now()) = 10, CDate("30/09/" & Year(Now())), IIf(Month(Now()) = 11, CDate("31/10/" & Year(Now())), IIf(Month(Now()) = 12, CDate("30/11/" & Year(Now())), CDate("31/12/1900")))))))))))))



The only caviate to using these statements is that it wont recognise when a leap year occurs, other than that, if it would work when deployed to the report server it would work perfectly for the purposes of what we need.



If anyone can see the flaw, or knows of a better and easier way of doing this please let me know.



Humble thanks,



Paul

View 3 Replies View Related

Execute Package Task Failed When Deployed To Server..

Feb 11, 2007

Hi,

I have a package that contains an Execute Package Task... it works fine when on my local machine and on our test-server.
After deploying the SSIS solution to our customers server, I open the project in Visual Studio and run the mainPackage in debug mode and the Task fails when trying to execute the package.. if I remove everything in the childpackage it still fails... the path to the package is correct and I know that I have rigths to execut it. I do not use any package security/encryption..
If i create a new package in the project and create a new fileconnection to it the Execute Package Task executes correctly, with the exact same content as the original package...

So my guess is that something in the FileConnetion object is set wrong, but i cannot understand what it is. The errormessage i get is something like this. "Execute Package Failed. Could not execute package".

Anyone had the same problem as I? I´m grateful for any help!

/erik

View 5 Replies View Related

Database Developed By SQL Server 2005 Express Edition Can Not Be Deployed In IIS?

Feb 17, 2007

I developed a site using Visual Web Developer 2005 and the database used is SQL Server 2005 Express edition.Everything works fine.  However, when I move the site to my IIS server, it says that my database is read-only.Is it because my SQL Server is an express edition? 

View 5 Replies View Related

How To Use 32-bit ODBC Driver (sybase) At An ETL Application Running (deployed Into SQL Server) On A 64-bit Machine ?

Oct 9, 2006

I am developing an ETL system on a 32-bit machine let's say, called 'dwdev'. The application connects to a Sybase database as a source system using ODBC connection. I am able to run this application directly from Visual studio 2005 and i am able to deploy it into SQL Server 2005 and run it from Server as a job. Both work. At this server i am connecting to a SQL Server instance called 'dwdev'.

When i transfer my application onto a 64-bit machine, let's say called 'dwtest', i am able to run my application from Visual Studio 2005 properly and it works, but when i deploy it into SQL Server (instance is called 'dwtest') and try to run it as a job just like the development machine, it gives an error and stops executing.

I was facing 'data source' type of error when i was first trying it from Visual Studio, but i solved this problem by setting Run64bitRunTime settings to FALSE on the Project's properties Debugging Page, at 64-bit machine. now it uses 32-bit runtime then 32-bit Sybase ODBC driver. But i cannot force the application to use 32 bit runtime when i am executing it from SQL Server as a job.

How can i do that? is there an alternative method?

Thanks for your help...

View 1 Replies View Related

Help With Converting Code: VB Code In SQL Server 2000-&&>Visual Studio BI 2005

Jul 27, 2006

Hi all--I'm trying to convert a function which I inherited from a SQL Server 2000 DTS package to something usable in an SSIS package in SQL Server 2005. Given the original code here:
Function Main()
on error resume next
dim cn, i, rs, sSQL
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"
set rs = CreateObject("ADODB.Recordset")
set rs = DTSGlobalVariables("SQLstring").value

for i = 1 to rs.RecordCount
sSQL = rs.Fields(0).value
cn.Execute sSQL, , 128 'adExecuteNoRecords option for faster execution
rs.MoveNext
Next

Main = DTSTaskExecResult_Success

End Function

This code was originally programmed in the SQL Server ActiveX Task type in a DTS package designed to take an open-ended number of SQL statements generated by another task as input, then execute each SQL statement sequentially. Upon this code's success, move on to the next step. (Of course, there was no additional documentation with this code. :-)

Based on other postings, I attempted to push this code into a Visual Studio BI 2005 Script Task with the following change:

public Sub Main()

...

Dts.TaskResult = Dts.Results.Success

End Class

I get the following error when I attempt to compile this:

Error 30209: Option Strict On requires all variable declarations to have an 'As' clause.

I am new to Visual Basic, so I'm on a learning curve here. From what I know of this script:
- The variables here violate the new Option Strict On requirement in VS 2005 to declare what type of object your variable is supposed to use.

- I need to explicitly declare each object, unless I turn off the Option Strict On (which didn't seem recommended, based on what I read).

Given this statement:

dim cn, i, rs, sSQL

I'm looking at "i" as type Integer; rs and sSQL are open-ended arrays, but can't quite figure out how to read the code here:

Set cn = CreateObject("ADODB.Connection")

cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"

set rs = CreateObject("ADODB.Recordset")

This code seems to create an instance of a COM component, then pass provider information and create the recordset being passed in by the previous task, but am not sure whether this syntax is correct for VS 2005 or what data type declaration to make here. Any ideas/help on how to rewrite this code would be greatly appreciated!

View 7 Replies View Related

SQL Server 2012 :: Data Grouping On 2 Levels But Only Returning Conditional Data

May 7, 2014

I think I am definitely thrashing and am not getting anywhere on something I think should be pretty simple to accomplish: I need to pull the total amounts for compartments with different products which are under the same manifest and the same document number conditionally based on if the document types are "Starting" or "Ending" but the values come from the "Adjust" records.

So here is the DDL, sample data, and the ideal return rows

CREATE TABLE #InvLogData
(
Id BIGINT, --is actually an identity column
Manifest_Id BIGINT,
Doc_Num BIGINT,
Doc_Type CHAR(1), -- S = Starting, E = Ending, A = Adjust
Compart_Id TINYINT,

[Code] ....

I have tried a combination of the below statements but I keep coming back to not being able to actually grab the correct rows.

SELECT DISTINCT(column X)
FROM #InvLogData
GROUP BY X
HAVING COUNT(DISTINCT X) > 1

One further minor problem: I need to make this a set-based solution. This table grows by a couple hundred thousand rows a week, a co-worker suggested using a <shudder/> cursor to do the work but it would never be performant.

View 9 Replies View Related

SSPI Handshake Failed With Error Code 0x8009030c While Establishing A Connection With Integrated Security; The Connection Has Be

Mar 7, 2006

Hello, I have a sql 2005 server, and I am a developer, with the database on my own machine. It alwayws works for me but after some minutes the other developer cant work in the application

He got this error

Login failed for user ''. The user is not associated with a trusted SQL Server connection. [CLIENT: 192.168.1.140]

and When I see the log event after that error, it comes with another error.

SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 192.168.1.140]

He has IIS5 and me too.

I created a user on the domain called ASPSYS with password, then in the IIS on anonymous authentication I put that user with that password, and it works, on both machines.



and in the connection string I have.

<add key="sqlconn" value="Data Source=ESTACION15;Initial Catalog=GescomDefinitiva;Integrated Security=SSPI; Trusted_Connection=true"/>

I go to the profiler, and I see that when he browses a page, the database is accesed with user ASPSYS, but when I browse a page, the database is accesed with user SElevalencia.

Thats strange.

The only way that the other developer can work again on the project is to restart the whole machine. He has windows xp profession, I have windows 2000.

If you want me to send logs please tellme



View 20 Replies View Related

Levels In A Cube

Feb 24, 2004

I have just started working the 2047 OLAP and came arcross the Analysis Service Limits. It states that the levels in a cube has a limit of 256 and the leves per dimension is 64. I am confused.

What is the definition of (levels in a cube)! and how are the levels in a cube different from (levels per dimension)

View 1 Replies View Related

FOR XML Query With More Than 2 Levels Of Data

Mar 30, 2006

I'm having trouble getting a FOR XML query to get the relationships correct when there are 3 levels of data.

In this example, I have 3 tables, GG_Grandpas, DD_Dads, KK_Kids. As you would expect, the Dads table is a child of the Grandpas table, and the Kids table is a child of the Dads table.

I'm using the Bush family in this example, these are the relationships:
- George SR
--- George JR
------ Jenna
------ Barbara
--- Jeb
------ Jeb JR
------ Noelle

These statements will create and populate the tables for the example with the above relationships:

SET NOCOUNT ON
DROP TABLE KK_Kids, DD_Dads, GG_Grandpas
CREATE TABLE GG_Grandpas ( GG_Grandpa_Key varchar(20) NOT NULL, GG_GrandpaName varchar(20))
CREATE TABLE DD_Dads ( DD_Dad_Key varchar(20) NOT NULL, DD_Grandpa_Key varchar(20) NOT NULL, DD_DadName varchar(20))
CREATE TABLE KK_Kids ( KK_Kid_Key varchar(20) NOT NULL, KK_Dad_Key varchar(20) NOT NULL, KK_KidName varchar(20))

ALTER TABLE GG_Grandpas ADD CONSTRAINT PK_GG PRIMARY KEY (GG_Grandpa_Key)
ALTER TABLE DD_Dads ADD CONSTRAINT PK_DD PRIMARY KEY (DD_Dad_Key)
ALTER TABLE KK_Kids ADD CONSTRAINT PK_KK PRIMARY KEY (KK_Kid_Key)
ALTER TABLE DD_Dads ADD CONSTRAINT FK_DD FOREIGN KEY (DD_Grandpa_Key) REFERENCES GG_Grandpas (GG_Grandpa_Key)
ALTER TABLE KK_Kids ADD CONSTRAINT FK_KK FOREIGN KEY (KK_Dad_Key) REFERENCES DD_Dads (DD_Dad_Key)

INSERT INTO GG_Grandpas VALUES ('GG_GEORGESR_KEY', 'GEORGE SR')
INSERT INTO DD_Dads VALUES ('DD_GEORGEJR_KEY', 'GG_GEORGESR_KEY', 'GEORGE JR')
INSERT INTO DD_Dads VALUES ('DD_JEB_KEY', 'GG_GEORGESR_KEY', 'JEB')
INSERT INTO KK_Kids VALUES ( 'KK_Jenna_Key', 'DD_GEORGEJR_KEY', 'Jenna' )
INSERT INTO KK_Kids VALUES ( 'KK_Barbara_Key', 'DD_GEORGEJR_KEY', 'Barbara' )
INSERT INTO KK_Kids VALUES ( 'KK_Noelle_Key', 'DD_JEB_KEY', 'Noelle' )
INSERT INTO KK_Kids VALUES ( 'KK_JebJR_Key', 'DD_JEB_KEY', 'Jeb Junior' )


So the question is, how do I get it to maintain the proper relationships between the records when I do an FOR XML query? Here is the query I am trying to get to work. Right now it puts all the Kids under a single Dad, rather than having them under their correct dads.
I am getting this, which is not what I want:

- George SR
--- George JR
--- Jeb
------ Jenna
------ Barbara
------ Jeb JR
------ Noelle


SELECT 1 as Tag,
NULL as Parent,
GG_GrandpaName as [GG_Grandpas!1!GG_GrandpaName],
GG_Grandpa_Key as [GG_Grandpas!1!GG_Grandpa_Key!id],
NULL as [DD_Dads!2!DD_DadName],
NULL as [DD_Dads!2!DD_Dad_Key!id],
NULL as [DD_Dads!2!DD_Grandpa_Key!idref],
NULL as [KK_Kids!3!KK_KidName],
NULL as [KK_Kids!3!KK_Dad_Key!idref]
FROM GG_Grandpas
UNION ALL
SELECT 2 ,
1 ,
NULL ,
GG_Grandpa_Key ,
DD_DadName ,
DD_Dad_Key ,
DD_Grandpa_Key ,
NULL ,
NULL
FROM GG_Grandpas, DD_Dads
WHERE GG_Grandpa_Key = DD_Grandpa_Key
UNION ALL
SELECT 3 ,
2 ,
NULL ,
GG_Grandpa_Key ,
NULL ,
DD_Dad_Key ,
NULL ,
KK_KidName ,
KK_Dad_Key
FROM GG_Grandpas, DD_Dads , KK_Kids
WHERE GG_Grandpa_Key = DD_Grandpa_Key
AND DD_Dad_Key = KK_Dad_Key

FOR XML EXPLICIT


I've tried it all different ways, but no luck so far.
Any ideas?

View 5 Replies View Related

Results Are Returning On Different Row Levels?

Feb 26, 2014

How do I get my data to show starting at the first row instead of skipping down?

Refer to the attachment.

Code:
CREATE PROCEDURE [dbo].[uspReportData]
-- Add the parameters for the stored procedure here
@Metric1 as varchar(50) = NULL, @Metric2 as varchar(50) = NULL, @Metric3 as varchar(50) = NULL, @Metric4 as varchar(50) = NULL,
@Metric5 as varchar(50) = NULL, @Metric6 as varchar(50) = NULL, @Metric7 as varchar(50) = NULL, @Metric8 as varchar(50) = NULL,

[code].....

View 1 Replies View Related

Transaction Isolation Levels

Feb 15, 2006

I am redesigning an application that distributes heldesk tickets to our50 engineers automatically. When the engineer logs into their window astored procedure executes that searches through all open tickets andassigns a predetermined amount of the open tickets to that engineer.Theproblem I am running into is that if 2 or more engineers log in at thesame time the stored procedure will distribute the same set of ticketsmultiple times.Originally this was fixed by "reworking" the way SQL Server handlestransactions. The original developer wrote his code like this:-----DECLARE @RET_STAT INTSELECT 'X' INTO #TEMPBEGIN TRANUPDATE #TEMP SET 'X' = 'Y'SELECT TOP 1 @TICKET_# =TICKET_NUMBER FROM TICKETS WHERE STATUS = 'O'EXEC @RET_STAT = USP_MOVE2QUEUE @TICKET_#, @USERIDIF @RET_STAT <> 0ROLLBACK TRANRETURN @RET_STATENDCOMMIT TRAN-----The UPDATE of the #TEMP table forces the transaction to kick off andlocks the row in table TICKETS until the entire transaction hascompleted.I would like to get rid of the #TEMP table and start using isolationlevels, but I am unsure which isolation level would continue to lockthe selected data and not allow anyone else access. Do I need acombination of isolation level and "WITH (ROWLOCK)"?Additionally, the TICKETS table is used throughout the application andI cannot exclusively lock the entire table just for the distributionprocess. It is VERY high I/O!Thanks for the help.

View 3 Replies View Related

Locks - Isolation Levels

May 22, 2006

Good morning,

I am trying to get my head around locking (row, table) and Isolation Levels. We have written a large .NET/SQL application and one day last week we had about two dozen people in our company do some semi "stress/load" testing of the app.

On quite a few occassions, a few of the users would receive the following error:

"Transaction (Process ID xx) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."

We are handling this on two fronts, the app and the database. The error handling in the app is being modified to capture this specific error and to retry the transaction.

However, from the database side, I am trying to find the most affective and efficient change to make regarding locking. I have been doing a lot of reading online and in BOL to get a better grasp of locking, but what I would really like is feedback from the community (forum) and get your thoughts on what changes I should make, if any, on the db side.

Thanks...

Scott

View 5 Replies View Related

Get The Names For Different Levels In A Table

Aug 20, 2007

hi

I've a table with coln names

ID
Name
ParentID
Level


I've list with different levels

say

ex.

the Data is:-

ID Name ParentID Level
1 Root null 1
2 Trunk 1 2
3 Branch 2 3
4 Leaf 3 4
5 Stem 3 4



How to write the query for getting the Names for different levels for corresponding ParentID....

Output should be like:-
Leaf Branch Trunk Root
Stem Branch Trunk Root

View 1 Replies View Related







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