I am looking for meta-information about the return recordset of a
stored-procedure. The procedure returns a resultset that contains columns of
more tables joined together. In all tables, I use, there is a
Record-Creation-Timestamp-Attribute. When joining two or more tables these
attribute-names appear in ther resultset but
i found no way to distinguish them.
I there a way to retrieve meta-information about the result-recordset of
such a stored-procedure?
CREATE PROCEDURE dbo.sp_Test_RetrieveData
@ID int
AS
SET NOCOUNT ON
select * from table1 inner join table2 on (FK_Tab2ID = Table2ID)
where table1.ID = @ID
GO
the resultset:
==========
Table1ID,FK_Tab2ID,CreatedAt,Table2ID,Description, CreatedAt
(the attribute CreatedAt appears twice.)
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Is there any possibility in SQL server 2005 to find out the source of some sql-query result? I need some kind of meta information about result I got. For example:
[if query is] select t1.id as id1, t2.id as id2, 67 as col67 from t1, t2
Hello, I'm building an ecommerce website which requires customers to create an account before they go ahead with a purchase. I have a createaccount.aspx page in Visual Web Developer 2005 with text boxes where users can enter their details (email, password, name and address). I'm trying to insert the information which users type into the text boxes into an SQL database table called Customers. I've dragged and dropped an SQL data source onto my page and have set it to operate on my AddCustomer stored procedure. I've confirgured my data source such that the parameter for each field in the database is set to the appropriate control on the webpage (for example the Email parameter source is "textboxEmail"). I've also placed a button onto my page so that the button click event can act as the trigger for sending the information in the text boxes to the database. I wasn't totally sure how to write code for the button click event such that when the button is clicked, the INSERT stored procedure runs. At the moment I'm using: Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click SqlDataSource1.Insert() End Sub When I try to run my application I'm getting an error which reads: Cannot insert the value NULL into column 'Email', table 'C:DOCUMENTS AND SETTINGSLUKE JACKSONMY DOCUMENTSVISUAL STUDIO 2005WEBSITESJACKSONSNURSERIESAPP_DATADATABASE.MDF.dbo.Customers'; column does not allow nulls. INSERT fails.The statement has been terminated. The error message implies that I haven't set the necessary parameters correctly but I really don't know where I'm going wrong! The code I'm using for my stored procedure is as follows: ALTER PROCEDURE AddCustomer ( @CustomerID int, @Email nvarchar(50), @Password nvarchar(MAX), @Name nvarchar(50), @Address1 nvarchar(50), @Address2 nvarchar(50), @Address3 nvarchar(50), @City nvarchar(50), @County nvarchar(50), @PostCode nvarchar(50) ) AS INSERT INTO Customers (Email, Password, Name, Address1, Address2, Address3, City, County, PostCode) VALUES (@Email, @Password, @Name, @Address1, @Address2, @Address3, @City, @County, @PostCode) I'd be really grateful if anyone could help me out with this. Thanks in advance, Luke p.s. just incase it helps, here's my createaccount.aspx page: <%@ Page Language="VB" MasterPageFile="~/Master.master" AutoEventWireup="false" CodeFile="createaccount.aspx.vb" Inherits="createaccount" title="Untitled Page" %> <%-- Add content controls here --%> <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"> <span style="text-decoration: underline"><strong>Create Account<br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="AddCustomer" SelectCommandType="StoredProcedure" InsertCommand="INSERT INTO Customers 	(Email, Password, Name, Address1, Address2, Address3, City, County, PostCode) 	VALUES 	(@Email, @Password, @Name, @Address1, @Address2, @Address3, @City, @County, @PostCode)"> <SelectParameters> <asp:Parameter Name="CustomerID" Type="Int32" /> <asp:ControlParameter ControlID="textboxEmail" Name="Email" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxPassword" Name="Password" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxName" Name="Name" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxAddress" Name="Address1" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxAddress2" Name="Address2" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxAddress3" Name="Address3" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxCity" Name="City" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxCounty" Name="County" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="textboxPostCode" Name="PostCode" PropertyName="Text" Type="String" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="Email" Type="String" /> <asp:Parameter Name="Password" Type="String" /> <asp:Parameter Name="Name" Type="String" /> <asp:Parameter Name="Address1" Type="String" /> <asp:Parameter Name="Address2" Type="String" /> <asp:Parameter Name="Address3" Type="String" /> <asp:Parameter Name="City" Type="String" /> <asp:Parameter Name="County" Type="String" /> <asp:Parameter Name="PostCode" Type="String" /> </InsertParameters> </asp:SqlDataSource> <br /> </strong></span> <table style="font-weight: bold; width: 394px; text-decoration: underline"> <tr> <td style="width: 111px; height: 21px; text-align: left"> Email:</td> <td style="height: 21px"> <asp:TextBox ID="textboxEmail" runat="server" Width="147px"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; height: 21px; text-align: left"> Password:</td> <td style="height: 21px"> <asp:TextBox ID="textboxPassword" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; height: 21px; text-align: left"> Name:</td> <td style="height: 21px"> <asp:TextBox ID="textboxName" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; text-align: left"> Address 1:</td> <td> <asp:TextBox ID="textboxAddress" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; height: 21px; text-align: left"> Address 2:</td> <td style="height: 21px"> <asp:TextBox ID="textboxAddress2" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; text-align: left"> Address 3:</td> <td> <asp:TextBox ID="textboxAddress3" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; text-align: left"> City:</td> <td> <asp:TextBox ID="textboxCity" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; height: 21px; text-align: left"> County:</td> <td style="height: 21px"> <asp:TextBox ID="textboxCounty" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 111px; text-align: left"> Post Code:</td> <td> <asp:TextBox ID="textboxPostCode" runat="server"></asp:TextBox></td> </tr> </table> <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> </asp:Content> Thanks again
I am trying to pull information about all the user created stored procedures in a database with a query. I have successfully pulled all the procs with parameters, but I want to result set to also contain the stored procedures without parameters. I can't quite get it. Any help would be appreciated:
SELECT procs.name as ProcName, params.name as ParameterName, types.name as ParamType, params.max_length, params.precision, params.scale, params.is_output FROM sys.procedures procs LEFT OUTER JOIN sys.all_parameters params ON procs.object_id = params.object_id LEFT OUTER JOIN sys.types types ON params.system_type_id = types.system_type_id
WHERE params.user_type_id = types.user_type_id AND procs.is_ms_shipped = 0 ORDER BY procname, params.parameter_id
Okay, so here's my dilemma: I'm trying to figure out a way I can get a list of drives, users, groups, etc. from computers on the network. There are a couple of caveats:
1) This has to be done entirely using T-SQL. There can be no external components that need to be installed. 2) xp_cmdshell can NOT be used, both for security reasons and because some of the computers being polled do not have SQL Server installed.
I would like to use the sp_OA* stored procedures. So far I have been able to connect to a remote server and find the running state of SQL Server; however, when it comes to enumerating collections I'm kinda lost.
This has also been posted in the MS-SQL general forum.
I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!
This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.
Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.
For example, even this simple little guy:
CREATE PROCEDURE BOB
AS
PRINT 'BOB'
GO
Gets created as a system stored procedure.
Any ideas what would cause that and/or how to fix it?
Hi all,I'm trying to get information about a given Stored Procedure (SP) but am able (until now) to get to extract only the name and columns either using T-SQL or SQLDMO. I want to extract information like which Tables the SP accesses, and also which Fields. This however doesn't seem to be available through T-SQL nor SQLDMO.I haven't been able to find any information yet, and am thinking that my only way to work this out is to design my own parser, which I've done to some extent - it extracts the tables and fields of every query inside the SP, but it gets a bit messy when the SP gets complicated, even when using regular expressions.I'm sure SQL must know a way to find out about these objects, since it manages to compile SP - so where does it maintain or (even better) expose information about the tables and fields each SP uses?Any help or pointers would be very very helpful!Regards,Pieter
Hi I have a stored procedure in SQL server 2005. It works fine when I execute it from the Management Studio.But when executing it from ASP.NET code like this: ..... Of course more code is executed before this call .....int retVal = this.odbcCreateDataBaseCommand.ExecuteNonQuery(); retVal is -1. But -1 doesn't really tell me what the problem is? Is there anyway to get extended error information so I can figure out whats going wrong? (The stored procedure was working fine in SQL server 2000 before I upgraded to SQL server 2005. I use .NET Framework 1.1 and ODBC Sql Native Client to access the 2005 server.) Regards Tomas
one of my SQL Developer member had one observation that, size of the parameter 'Parameter_XYZ' in certain stored procedure had changed from 25 to 255 during some production fixes, however suddenly its looks like that, someone has changed it back to 25 instead of 255.
DECLARE @Parameter_XYZ varchar(25);
Can we figure out in which sprint/drop the stored procedure was changed and the Parameter_XYZ back to 25. Can any log recovery mechanism will get such details.
Can we get stored procedure text between different alteration.
How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out? SELECT TABLE_SCHEMA + '.' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID, S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName', T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID FROM [Item].ItemDetails I INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID FROM [Item].ItemDetails IOr something like that... Any thoughts?
I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.
How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?
We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.
For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.
I can't update the sys.Objects or sys.Procedures views in 2005.
What effect will this flag (is_ms_shipped = 1) have on my stored procedures?
Can I move these out of "System Stored Procedures" and into "Stored Procedures"?
I am writing a set of store procedures (around 30), most of them require the same basic logic to get an ID, I was thinking to add this logic into an stored procedure.
The question is: Would calling an stored procedure from within an stored procedure affect performance? I mean, would it need to create a separate db connection? am I better off copying and pasting the logic into all the store procedures (in terms of performance)?
Hi all - I'm trying to optimized my stored procedures to be a bit easier to maintain, and am sure this is possible, not am very unclear on the syntax to doing this correctly. For example, I have a simple stored procedure that takes a string as a parameter, and returns its resolved index that corresponds to a record in my database. ie exec dbo.DeriveStatusID 'Created' returns an int value as 1 (performed by "SELECT statusID FROM statusList WHERE statusName= 'Created') but I also have a second stored procedure that needs to make reference to this procedure first, in order to resolve an id - ie: exec dbo.AddProduct_Insert 'widget1' which currently performs:SET @statusID = (SELECT statusID FROM statusList WHERE statusName='Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID) I want to simply the insert to perform (in one sproc): SET @statusID = EXEC deriveStatusID ('Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID) This works fine if I call this stored procedure in code first, then pass it to the second stored procedure, but NOT if it is reference in the second stored procedure directly (I end up with an empty value for @statusID in this example). My actual "Insert" stored procedures are far more complicated, but I am working towards lightening the business logic in my application ( it shouldn't have to pre-vet the data prior to executing a valid insert). Hopefully this makes some sense - it doesn't seem right to me that this is impossible, and am fairly sure I'm just missing some simple syntax - can anyone assist?
Hi Guys, I have a DataBase in which I have several Tables. What I want is an SP or Query which takes as its parameter the "tablename". The Output Should be a having three fields only. Field name, DataType Of the Field, Length of the DataType. For Example Suppose the StoredProcedure Name is "SP_GetTables" if i have a table named "tbl_Users" with fields UserName varchar(50) UserPass varchar(20) UserAge int UserStatus bit In my program side if I pass the parameter as "tbl_Users" to the StoredProcedure SP_Users, I should get the O/P as Field Name DataType Length UserName varchar 50 UserPass varchar 20 UserAge int UserStatus bit Regards, Naveen.
Hello all, I use Asp.net 1.1 vb script and MS SQL server 2000. I'm wondering if there's a way to put a database field into the title meta tag. For example if I have a detail page for cars which pulls the text info from the SQL data base and I want the field "name" in the title tag details.aspx?name=Hummer would have the Title meta tag as Cars..."Hummer" and details.aspx?name=Corvette would have the Title meta tag as Cars..."Corvette" so that for each car showing in details.aspx page it wouldn't have to have the same title tag for search engines
Hi,I would like to prepare a data dictionary for my database (northwind).I have framed the below SQLSELECT'NAME ' = a.name,'DESCRIPTION' = b.value,'Type ' = type_name(a.xusertype),' ' AS 'Values','NULL ' = case when a.isnullable = 0 then ' ' else 'X' end,' ' AS 'PK',' ' AS 'FK'FROMsyscolumns a,sysproperties bWHEREa.id = 2073058421 AND --- Customers Tablea.number = 0 ANDb.id = a.id ANDb.smallid = a.colidORDER BY a.colidand the output would be:NAME DESCRIPTION Type Values NULL PK FK-------------- --------------- ---------- ------ ----- ---- ----CustomerID Customer ID ncharCompanyName Company Name nvarcharContactName Contact Name nvarchar XContactTitle Contact Title nvarchar XAddress Address nvarchar XCity City nvarchar XRegion Region nvarchar XPostalCode Postal Code nvarchar XCountry Country nvarchar XPhone Phone # nvarchar XFax Fax # nvarchar XPK and FK is where I need to print whether the column is Primary Key orForeign Key.If CustomerId is defined as Primary Key then PK should have X printed.Thats the objective.How will I accomplish this ?Thanks in advance,Anu
I am wanting to set up some kind of metadata catalogue to managemetadata records of the data we collect and create for my companiesclients.I am thinking I want to do this using XML and SQL Server and have sometype of web-based browser to search for records.Any suggestions on existing applications or resources that I could use?Thanks
Hi,Apologies if this is better posted in an ASP group, but here goesanyway ...Is it possible to work out what parameters a stored procedure expects,using ASP?I would like to take the name of a stored procedure, work out whatinput parameters it has and build a form based on them in ASP.Thanks,MB.
Okay... We have a SQL2K database that has about 500 tables or so. It is normalized to a reasonable level and enforces all relationships with PK/FKs, not triggers. Hence, for a database-minded person it is fairly easy to read (as easy as a 500+ table database can be!).
Our users need adhoc query capabilities. Our report writer is simply overwhelmed. He doesn't need to be spending time writing a report that is intended to be run once.
I expect the best alternative would be to use some sort of adhoc reporting tool that is based off meta data. We (the DBAs) could be responsible for maintaining the meta data and STILL have a manhour savings over developing all these reports.
Here's the catch... We are on a TIGHT budget (aerospace industry is still reeling a bit). Is anyone using a product or aware of a product that might be just the ticket for us? We have been investigating a product by LogiXML called LGX AdHoc (http://www.logixml.com/products/AdHoc/adhoc.htm). Looks promising. Anyone use or familar with it?
My customer has a .NET application that reads meta data from SQL Server, Oracle, DB2, and several propritary databases. Because each DBMS stores the meta data using various techniques, they have written custom code for each DBMS. They are working on a generic ODBC/OLEDB suppport, but in the interim I was trying to use SQL Server to link to an Access database. The Access linked server works fine for queries in Query Analyzer, but I would like to be able to programatically read the metadata for an Access DB (tables, columns, types, etc) via the linked server. SQL Server's usual mechanism for storing meta-data in the Master database aparently is not used for Linked Servers.
Does SQL Server expose Linked Server meta data? How would one retrieve this meta data if it is exposed?