SqlParameter With ParameterName '@NewID' Is Not Contained By This SqlParameterCollection
Mar 27, 2007
Hi,
What I am trying to do is to get the new ID for every record is inserted into a table. I have a For...Each statement that does the loop and using the sqldatasource to so the insert. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ myConnectionString%>">
<InsertParameters>
<asp:Parameter Name="NewID" Type="int16" Direction="output" />
</InsertParameters>
</asp:SqlDataSource> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sqlSelect As String
Session("Waste_Profile_Num") = 2
Session("Waste_Profile_Num2") = 5
sqlSelect = "SELECT Range, Concentration, Component_ID FROM Component_Profile WHERE (Waste_Profile_Num = " & Session("Waste_Profile_Num").ToString() & ")"
SqlDataSource1.SelectCommand = sqlSelect
Dim dv As Data.DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), Data.DataView)
For Each dr As Data.DataRow In dv.Table.Rows
Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted
Session("NewID") = e.Command.Parameters("@NewID").Value.ToString
End Sub What I have done so far is to display the new id and I am going to use that return id later. However, the first time through the loop, I am able to get the new id but not the second time. So, I wonder, how do I every single new id each time the INSERT statement is executed?STAN
Stored procedure:1 ALTER PROCEDURE [dbo].[insert_DagVerslag] 2 -- Add the parameters for the stored procedure here 3 @serverID int, 4 @datum datetime, 5 @ID int OUTPUT 6 AS 7 BEGIN 8 -- SET NOCOUNT ON added to prevent extra result sets from 9 -- interfering with SELECT statements. 10 SET NOCOUNT ON; 11 -- Insert statements for procedure here 12 BEGIN TRANSACTION 13 INSERT Log ( serverID, datum) 14 VALUES( @serverID, @datum) 15 COMMIT TRANSACTION 16 SET @ID = @@identity 17 END 18
Method who is calling the stored procedure and causes the error1 public void AddDagVerslag(Historiek historiek) 2 { 3 SqlConnection oConn = new SqlConnection(_connectionString); 4 string strSql = "insert_DagVerslag"; 5 SqlCommand oCmd = new SqlCommand(strSql, oConn); 6 oCmd.CommandType = CommandType.StoredProcedure; 7 oCmd.Parameters.Add(new SqlParameter("@serverID", SqlDbType.Int)).Value = historiek.ServerID; 8 oCmd.Parameters.Add(new SqlParameter("@datum", SqlDbType.DateTime)).Value = historiek.Datum; 9 oCmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)); 10 11 oCmd.Parameters["@ID"].Direction = ParameterDirection.Output; 12 13 try 14 { 15 oConn.Open(); 16 int rowsAffected = oCmd.ExecuteNonQuery(); 17 if (rowsAffected == 0) throw new ApplicationException("Fout toevoegen historiek"); 18 oCmd.Parameters.Clear(); 19 historiek.HistoriekID = System.Convert.ToInt32(oCmd.Parameters["@ID"].Value); 20 21 foreach (HistoriekDetail hDetail in historiek.LstHistoriekDetails) 22 { 23 AddDagVerslagCategorie(historiek.HistoriekID, hDetail); 24 } 25 } 26 catch (Exception ex) 27 { 28 throw new ApplicationException("Fout toevoegen historiek : " + ex.Message); 29 } 30 finally 31 { 32 if (oConn.State == ConnectionState.Open) oConn.Close(); 33 } 34 }
Whats going wrong, i've added the ID parameter my ParameterCollection... so why cant it be found
Hello All, I'm having a problem tracking down why my app is not instantiating a parameter in a sqldatasource, when I'm expecting it to do so. When the app fails, this info is displayed:
Server Error in '/' Application.-------------------------------------------------------------------------------- An SqlParameter with ParameterName @createdby is not contained by this SqlParameterCollection. 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.IndexOutOfRangeException: An SqlParameter with ParameterName @createdby is not contained by this SqlParameterCollection. Source Error: Line 30: Private Sub SqlDataSource1_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.DeletingLine 31: e.Command.Parameters.Item("@createdby").Value = CType(Membership.GetUser.ProviderUserKey, Guid)Line 32: Line 33: End Sub Source File: ...filename... Line: 31 Stack Trace: [IndexOutOfRangeException: An SqlParameter with ParameterName @createdby is not contained by this SqlParameterCollection.] System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName) +713105 System.Data.Common.DbParameterCollection.get_Item(String parameterName) +7 diabetes.reading.SqlDataSource1_Deleting(Object sender, SqlDataSourceCommandEventArgs e) in C:Documents and SettingsAlbertMy DocumentsVisual Studio 2005Projectsdiabetesdiabetesdiabetes eading.aspx.vb:31 System.Web.UI.WebControls.SqlDataSourceView.OnDeleting(SqlDataSourceCommandEventArgs e) +114 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +682 System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +75 System.Web.UI.WebControls.FormView.HandleDelete(String commandArg) +839 System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +556 System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 Here's the datasource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DiabetesOne %>" DeleteCommand="reading_delete" DeleteCommandType="StoredProcedure" > <DeleteParameters> <asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" /> <asp:Parameter Name="rid" Type="Int32" /> <asp:Parameter Name="createdby" Type="Object" /> </DeleteParameters> </asp:SqlDataSource> Here's the beginning of the stored procedure showing the parameters:
CREATE PROCEDURE [dbo].[reading_delete] @rid int,@createdby sql_variantASset nocount on;begin try...the procedural code... Here's debugger capture, pointing to same issue:
System.IndexOutOfRangeException was unhandled by user code Message="An SqlParameter with ParameterName @createdby is not contained by this SqlParameterCollection." Source="System.Data" StackTrace: at System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName) at System.Data.Common.DbParameterCollection.get_Item(String parameterName) at diabetes.reading.SqlDataSource1_Deleting(Object sender, SqlDataSourceCommandEventArgs e) in C:... at System.Web.UI.WebControls.SqlDataSourceView.OnDeleting(SqlDataSourceCommandEventArgs e) at System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) at System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback)
I've inspected the sqldatasourcecommandeventargs command.parameters in the deleting method during debugging and could not find the parameter in the array, although I "think" it should be because it's explicitly stated in the sqldatasource parameters declarations. I see two parameters in the array, @RETURN_VALUE and @RID, both of which are expected and coincide with the declaration in the stored procedure and the sqldatasource.
I have a site which works fine with an Access DB, I now want to upsize it to use a SQL DB... I have changed my OleDB Commands etc... And Used SqlCommands and everything seems fine..Only one problem I have and its really stumped me... I always used SQLDataSource for the app even with the AccessDB, as I knew I would be upsizing at some point. We I have the below SQLDataSource 1 <asp:SqlDataSource ID="RandomBusinessDataSource" runat="server" 2 ConnectionString="<%$ ConnectionStrings:SQLDataBaseConnectionString %>" 3 SelectCommand="SELECT TOP (1) intBusinessID, txtBusinessName, intSubCatID, intCatID, txtTelNo, txtPostCode, txtWebAdd, txtReferred, bitBusinessShow, txtLong, txtLat, memBusinessDesc, intIPAddress, bitBusinessPaid FROM tblBusiness WHERE (intBusinessID = @Param1)" OnSelecting="RandomBusinessDataSource_Selecting">4 <SelectParameters>5 <asp:Parameter Name="Param1" Type="Int32" />6 </SelectParameters>7 </asp:SqlDataSource> Very Simple.... I have my function that is creating my random number and returning a VALID intbusinessID ... And now I have this OnSelecting event1 Protected Sub RandomBusinessDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)2 e.Command.Parameters("Param1").Value = MyNewRandomNum3 End Sub But when I try and run the page I get the following error (Don't forget this page IS working using the SQLDataSource and an Access DB??)An SqlParameter with ParameterName 'Param1' is not contained by this SqlParameterCollection. I am a bit confused?? why would it say this now... Yet it works fine if I just change the connectionString to the access DB?? Any helps very much appreciated... Thanks
Hi! I'm doing a class for working with MSDE. My goal (as you understood) is to separate business and data layers. I'm facing the following problem: I have to use something like cmd.Parameters.Add("@Name", value) in my business layer to avoid using cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 16, value) where you can see that 'SqlDbType.NVarChar' doesn't respect the 'rules' for separating Data/Business layer.
Does it cost a lot to use a 'light' constructor (more job for the SQL engine to convert datas)?
Do I have to do a special function in my 'Data class' to convert an Int32 to a SqlDbType.Int for example?
I could see that Parameters.Add is deprecated and I have to use Parameters.AddWithValue in .Net 2 when you have only 2 parameters. Is there a better way to handle that?
RunProc("test",param); RunProc("test",param); //if i remove this line ,it's OK } public void RunProc(string procName, SqlParameter pram) { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); con.Open();
I currently have a connection class that handles all of my database connectivity. What I am trying to do is build a SqlParameterCollection object on one page, then pass that object to my connection class. Is it possible to do this? I am not getting any compilation errors, but I can not get the parameters to be recognized. Here is what I am trying to do:
conn.OpenReader(sql, newcollect); while (conn.DR.Read()) { read data onto page here... } conn.CloseReader();
Page 2 (connection class) :
public void OpenReader(string sql, SqlParameterCollection collect) { Conn = new SqlConnection(strConn); Conn.Open(); Command = new SqlCommand(sql,Conn);
Command.Parameters.Add(collect); <------This is the root of my question Command.CommandTimeout = 300; // executes sql and fills data reader with data DR = Command.ExecuteReader(); }
Can you do this??? And if so, can anyone tell me why the statement will not return any data? The procedure works perfectly, and will work if I use the standard way of passing the parameters to the command statement.
suppose,the type of the stored procedure's paramters is varchar .I hate to add parameterNames and types.If i can read the string of the stored procedure the get the paramterNames by operating text? public void storeOperate(string stringParameter,string name) { string[] strs=stringParameter.Split('&'); SqlConnection conn = new SqlConnection(getConnectionString.getconnectionString()); SqlCommand cmd=new SqlCommand(name,conn); cmd.CommandText=name; cmd.CommandType=CommandType.StoredProcedure; foreach(string str in strs) { cmd.Parameters.Add(".....",SqlDbType........).Value=str; //my trouble } conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); cmd.Dispose(); }
I'm using parameters to record into database like: SqlParameter paramId_empresa = new SqlParameter("@Id_empresa", SqlDbType.Int, 4); paramId_empresa.Value = idEmpresa; myCommand.Parameters.Add(paramId_empresa); And set sql server field to allow null values and default value as (null) Trouble is I'm getting an Input string was not in a correct format. when the field is blank Line 182:Line 183: myConnection.Open();Line 184: myCommand.ExecuteNonQuery();Line 185: myConnection.Close();Line 186: }
I am unable to set the value of my SqlParameter unless it is to a string.sqlCmd.Parameters.Add('@myParameter', SqlDbType.Bit).Value := false; Setting it to false or 0 results in error: "Incompatible types: 'Object' and 'Boolean' (or 'Integer')" I've tried to cast them as objects and that didn't work. I don't understand why something like 'false' (as a string) will. FYI: I'm using Delphi.NET and hating it.
Im trying to execute the following:mySqlCmd.Parameters.Add("@Parent_ID", SqlDbType.Int).Value = (sectionUpdate.iSection.ParentID == 0 ? DBNull.Value : myParentID); However i get an error that Null cant be converted to Int. Is there any way i can uyse the SqlParameters approach but pass in a Null value for the field or must i wrap the entire connection within a IF/ELSE statement one containing a hard-coded NULL within the query and the other as a standard parameter with a proper int value? Thanks
Hi I am writing an app in flash which needs to hook up to MS SQL via asp.I need the code below to pass the var (ptodaysDate) to the sql statement. I can hard code it in and it works great but I really need to pass the var from flash.Pulling my hair out here, not much left to go.Any help greatly appreciated.---------------------------------------------- [WebMethod] public Schedule[] getSchedule(int ptodaysDate) { SqlDataAdapter adpt = new SqlDataAdapter("SELECT scheduleID, roomName, eventType,unitName,groupName,staffName,staffName2,theDate,theEnd FROM tb_schedule Where theDate >= @rtodaysDate", connString); SqlParameter rtodaysDate = new SqlParameter("@rtodaysDate", ptodaysDate); DataSet ds = new DataSet(); ArrayList al = new ArrayList(); adpt.Fill(ds); foreach (DataRow row in ds.Tables[0].Rows) { Schedule obj = new Schedule(); obj.scheduleID = (int)row["scheduleID"]; obj.roomName = (string)row["roomName"]; obj.eventType = (string)row["eventType"]; obj.unitName = (string)row["unitName"]; obj.groupName = (string)row["groupName"]; obj.staffName = (string)row["staffName"]; obj.staffName2 = (string)row["staffName2"]; obj.theDate = (string)row["theDate"]; obj.theEnd = (string)row["theEnd"]; al.Add(obj); } Schedule[] outArray = (Schedule[])al.ToArray(typeof(Schedule)); return outArray; } public class Schedule { public int scheduleID; public string roomName; public string eventType; public string unitName; public string groupName; public string staffName; public string staffName2; public string theDate; public string theEnd; }
The FULL System.Data.SqlDbType reference seems unnecessary? Is there something I am doing wrong or something that should be added to Web.Config? If I try ONLY ",SqlDbType," it will not compile?
MY CODE: SqlParameter AName; AName = myCommand.Parameters.Add("@AName",System.Data.SqlDbType.VarChar,50);
The SqlParameter with ParameterName '@pk' is already contained by another SqlParameterCollection
If I could work out what code to post I would, but I can say that I am managing my Sql data in my code by caching small arrays of SqlParameter objects as pulled from the database. If I need to update the DB I change the cached SqlParameter and re-insert it. If I perform a SELECT I check the cache first to see if I already have the SqlParameter. However, currently, I am experiencing the above error when performing a select, then later an update, followed by another update. Would I be correct in saying that a SqlParameter object can only be used once for a database operation and should be discarded? Would I be correct if I said that the SqlCommand object should be discarded? I am barking up the wrong tree entirely?
Is it possible to have a SqlParameter setup as an Output, and get it to return @@Identity without using a stored procedure?
I have an INSERT statement, written as TEXT in my code (at the time being, I cannot create stored procedures). I'm trying to find out how to return the created IDENTITY that was generated.
Can someone please explain to me how this works? Thanks.
hi I am creating a stroed procedure which suppose to update an image column of the given row. I have created the same procedures before which worked fine with texts and numbers but not with Images. this procedure get table name,row Id, column name of the image, and image data. like:
Create PROCEDURE [dbo].[spImageUpd]
(
@TableName varchar(100),
@Id int,
@ImageColName nvarchar(100),
@ImageData image
) begin ?????? end
I tryed to use set @sql='update '+ @TableName+ ' set '+@ImageColName + '=' + @ImageDt' + ' where Id='+ cast(@Id as nvarchar(10)) EXEC sp_executesql @query = @sql, @params = N'@ImageDt">N'@ImageDt Image', @ImageDt = @ImageData but sp_executesql just accept text as params. is it possible to fix this problem? thank you in advance regards
Dear Folks, can you please tell me, how many newid's can be generated by an sql server instance? and the newid generated by one instance can possibly be generated by another instance ? please give me brief regarding this
Is there a limitation of using:set @sessionID = NEWID()would there be a simular NEWID() being generated if used in a databaseapplication.Eugene Anthony*** Sent via Developersdex http://www.developersdex.com ***
hi ; I am abut searching in a database that html data stored in it, I want to search something like this: search me And it stored like this: search <b> me </b> I don’t know how to remove html tags on stored procedure,
It will be great if you direct me to a search stored procedure that handle this it rather make the sorting and paging stuff too .
I am just learning ASP.net, been reading over data grids but I am having a tough time understanding what the parameter line would be used for. I have read the MSDN regarding parameters, they seem to make sense. But the whole System.Byte(0) I cannot understand. sqlUpdateCommand1 = new SqlCommand(); sqlUpdateCommand1.Parameters.Add(new SqlParameter("@Original_SSN", SqlDbType.VarChar, 11, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "SSN", DataRowVersion.Original, null)); Any pointers or tutorials regarding this is much appreciated. Thanks, Rishi Dhupar
Below I have pasted the error message, hidden form fields, function code and even the stored procedure code. I'd be most grateful if anyone can show me the error of my ways!
Thanks, theSpike
I'm calling a stored procedure and besides several varchar fields, I'm passing two integer values (employeeID and businessID). These values come from hidden fields on a form and it's the businessID that throws the format error. I call the same stored procedure for both insert and update (the SP evaluates employeeID to decide btwn insert/update) and the insert works perfectly, but the update throws the format exception error. The only difference is that the employeeID is 0 (zero) for an insert and > 0 when it's updating. I strikes me as particularly bizzare that the line that throws the exception is the businessID, not the employeeID because the businessID is the same value for both insert and update. It's the employeeID that is subject to change.
The error: Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 147: //businessID Line 148: SqlParameter businessID = new SqlParameter("@businessID",SqlDbType.Int,4); Line 149: businessID.Value = Convert.ToInt32(hdnBusinessID.Value); Line 150: businessID.Direction = ParameterDirection.Input; Line 151: theCommand.Parameters.Add(businessID);
I'm calling the SAME function for the insert and update, the same hiddent form fields exist <input name="hdnBusinessID" id="hdnBusinessID" type="hidden" value="1" /> <input name="hdnEmployeeID" id="hdnEmployeeID" type="hidden" value="7" /> Here's the function that get's called:
void btnAddEmployee_Click(object sender, EventArgs e) { int intNewEmployeeID; string connectionstring = ConfigurationSettings.AppSettings["ConnectionString"]; SqlCommand theCommand = new SqlCommand(); theCommand.CommandText = "AMS_EmployeeSave"; theCommand.Connection = new SqlConnection(connectionstring); theCommand.CommandType = CommandType.StoredProcedure;
// Add parameters to SqlCommand //employeeID SqlParameter empID = new SqlParameter("@employeeID",SqlDbType.Int,4); empID.Value = Convert.ToInt32(hdnEmployeeID.Value); empID.Direction = ParameterDirection.Input; theCommand.Parameters.Add(empID);
-- passed in ID = 0 means they're adding a new employee so do insert if @employeeID = 0 begin select @alreadyExists = count(*) from dbo.AMS_employee where emp_email = @email if @alreadyExists = 0 begin insert into AMS_employee (emp_businessID, emp_title, emp_firstName, emp_middleName, emp_lastName, emp_suffix, emp_email, emp_password) values (@businessID, @title, @firstName, @middleName, @lastName, @suffix, @email, @password)
select @newEmployeeID = @@identity end
else -- there is already an employee with that email address select @newEmployeeID = -1 end
-- passed in ID > 0 means they're updating existing employee so do update else if @employeeID > 0 begin update AMS_employee set emp_title = @title, emp_firstName = @firstName, emp_middleName = @middleName, emp_lastName = @lastName, emp_suffix = @suffix, emp_email = @email where emp_ID = @employeeID
select @newEmployeeID = @employeeID
-- only update the password if it one was provided if len(rtrim(@password)) > 0 begin update AMS_employee set emp_password = @password where emp_ID = @employeeID end
i don't know if this is the right forum to post to, but here i go:
I'm having a problem... I need to delete several records having as criteria their pk. The deletion is made using SqlParameter in the code and a stored procedure on server.
as far as i know, i can do this, either using a IN list:
- build and pass the list of id's from code to the sp: delete from tbl where attachment.id in (1,2,3)
OR
- execute a simple delete several times.
So far i tried first option, but i get errors in converting the list to ints; that is what the sql engine says. I prefer this option because i think is faster and requires less roundtrips to the sql server.
My questions are: 1. how do i build a sane IN list? 2. is it worth to use a delete in a loop? the records that must be deleted are 5 at most, per job. 1 job can have [0..5] attachments.
when you use newid() is that a new uniqueidentifier for the database or for the table???I have a changelog that captures newly created users first and gives them a newid, then i want to approve that change and copy the newid generated for that user into the user table. Will I run into duplicate id's that way???
Excuse my ignorance because I don't do advance db related programming,but have no other choice at the moment. My experience is limited tosimple queries.I need to have the following query display the recordset in random orderbased on RecordID (unique key) if possible. I tried the ORDER BY NewID()at the end and it generated an error (ORDER BY items must appear in theselect list if SELECT DISTINCT is specified.) I guess because of the subquery. I would also like for the recordset to display a different 10records on each hit to the page, not just the same 10 records in randomorder. I wasn't sure if the SELECT commands I have in place aresufficient for this task.Thanks in advance for any assistance.SELECT DISTINCTTOP 10 dbo.ShowcaseRides.RecordID,dbo.ShowcaseRides.CustomerID, dbo.ShowcaseRides.PhotoLibID,dbo.ShowcaseRides.Year,dbo.ShowcaseRides.MakeShowcase,dbo.ShowcaseRides.ModelShowcase, dbo.ShowcaseRides.VehicleTitle,dbo.ShowcaseRides.NickName,dbo.ShowcaseRides.SiteURL,dbo.ShowcaseRides.ShowcaseRating, dbo.ShowcaseRides.ShowcaseRatingImage,dbo.ShowcaseRides.ReviewDate,dbo.ShowcaseRides.Home,dbo.ShowcaseRides.EntryDate, dbo.Customers.UserName,dbo.Customers.ShipCity, dbo.Customers.ShipRegion,dbo.Customers.ShipPostalCode,dbo.Customers.ShipCountry, dbo.Customers.LastName,dbo.Customers.FirstName, dbo.Customers.MemberSince,dbo.ShowcaseRides.Live,dbo.ShowcaseRides.MemberLive, dbo.Accessories.Make,dbo.Accessories.Model, Photos.PathFROM dbo.ShowcaseRides INNER JOINdbo.Customers ON dbo.ShowcaseRides.CustomerID =dbo.Customers.CustomerID INNER JOINdbo.Accessories ON dbo.ShowcaseRides.MakeShowcase= dbo.Accessories.MakeShowcase ANDdbo.ShowcaseRides.ModelShowcase =dbo.Accessories.ModelShowcase INNER JOIN(SELECT MIN(dbo.ShowcasePhotos.PhotoPath)AS Path, RecordIDFROM dbo.ShowcasePhotosGROUP BY RecordID) Photos ONdbo.ShowcaseRides.RecordID = Photos.RecordID INNER JOINdbo.ShowcasePhotos ON Photos.Path =dbo.ShowcasePhotos.PhotoPathWHERE (dbo.ShowcaseRides.MemberLive = 1) AND (dbo.ShowcaseRides.Live= 1) AND (dbo.ShowcaseRides.MakeShowcase = @MMColParam)ORDER BY dbo.ShowcaseRides.EntryDate DESCRegards,Darin L. MillerParadyse Development~-~-~-~-~-~-~-~-~-~-~-~-~-~-"Some things are true whether you believe them or not." - Nicolas Cagein City of Angels
I would like to perform an audit of weak passwords, which is well documented for sql users. Using the same methodology, I should be able to audit weak passwords for contained users. To accomplish this, I must be able to find the location of the password hashes for the contained users.
I have looked at sys.syslogins and sys.sql_logins, which both have the password hash for server level users, but not contained users. I was able to find sys.sysusers, which does contain contained users, but no password hash.
What is the location of the password hashes for contained users?
I know that anything in a CDATA section will be ignored by an XML parser. Does that hold true for the SSIS XML Source?
I am trying to import a large quantity of movie information and all of the reviews, synopsis, etc are contained in CDATA. example:
<synopsis size="100"><![CDATA[Four vignettes feature thugs in a pool hall, a tormented ex-con, a cop and a gangster.]]></synopsis>
Sounds like a good one, no?
The record gets inserted into the database however it contains a NULL in the field for the synopsis text. I would imagine that the reason for this would fall at the feet of CDATA's nature and that SSIS is ignoring it.
We've got an app that is in final testing so we can't go around forcing SqlDbType.VarChar. Is there any way to make SqlParameter default to varchar if you don't explicitly set a type for a string value? It's bad for our db index usage because they're all varchar and nvarchar forces a convert_implicit messing up performance.
Why am I getting a different numbers of distinct ids in those queries?
USE AdventureWorks go Declare @myXml as xml set @myXml = ' <lol>omg</lol> <lol>rofl</lol> ';
select locations.*, T.c.value('.','nvarchar(max)') from ( select newid() as Id from Production.ProductModel where ProductModelID in (7, 8) ) as locations cross apply @myXml.nodes('(/lol)') T(c);
select mytable.* , T.c.value('.','nvarchar(max)') from ( select newid() as Id union select newid() ) as mytable cross apply @myXml.nodes('(/lol)') T(c);
I've been trying to figure out why these two return a different amount of distinct ids... Is that a bug in optimization?
Code Snippet
USE AdventureWorks go Declare @myXml as xml set @myXml = ' <lol>omg</lol> <lol>rofl</lol> ';
WITH locations as ( select newid() as Id from Production.ProductModel where ProductModelID in (7, 8) ) select locations.*, T.c.value('.','nvarchar(max)') from locations cross apply @myXml.nodes('(/lol)') T(c);
with mytable as ( select newid() as Id union select newid() ) select mytable.* , T.c.value('.','nvarchar(max)') from mytable cross apply @myXml.nodes('(/lol)') T(c);
I have a view which at the moment has no unique identifier on each record. When I try adding a column definition to the view such as NEWID() as TransactionId, the view then cannot 1) be selected into a temporary table, or 2) queried on other columns in the table. In either case I end up with an empty result set.
I believe I have a way around this for my purpose, which was principally testability. However, can anyone enlighten me as to how and why this happens?
Hi, I have a Table that contains SQL queries in one of its columns.I need to execute those query and finally want to retrive the result in another table i cannot use Cursors,Its working extremely slow, near about 1 min only for 2000 rows.Please tell me how can i minimize my time.Or any solution (without cursor) for such problem.Please help its very urgent.e.g Say TableContainQuery(PKID,QueryField) Now above table have 10000 of records, I need to retrieve data from by executing queries contain in above table. I am using SQL Server. Regards,Dheeraj