Search Results

Search found 1100 results on 44 pages for 'dbo'.

Page 28/44 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Stored Procedure could not be found

    - by Beatles1692
    We use SQL server 2008 as our RDBMS and we have a database that has a different user rather than dbo as its owner. The problem is in one machine a stored procedure can not run unless its owner is mentioned. If we connect to our database using this user and try to execute the following : exec ourSP we get a "could not find ourSP" error but this works fine: exec user.ourSP Does anybody knows what can lead to such a strange behavior?

    Read the article

  • How to insert values using Joins in asp.net stroed procedure?

    - by Samba Siva
    CREATE PROC [dbo].[K_HRM_Insert_VehicleAssign] @vehiclename varchar(50), @empname varchar(50), @updatedby varchar(50), @updatedon datetime as begin insert into K_MasterEmpDetails ME inner join K_HRM_Vehicle_Assign VA on VA.[empname+id] = ME.Firstname +' '+ME.Lastname+' - '+ME.kjlid as ME.Employee (VA.vehiclename,ME.Employee,VA.updatedby,VA.updatedon)values(@vehiclename,@empname, @updatedby,getdate()) end I am getting an error near ME...please help me

    Read the article

  • Generate T-SQL for Existing Indexes

    - by Chris S
    How do you programmatically generate T-SQL CREATE statements for existing indexes in a database? SQL Studio provides a "Script Index as-Create to" command that generates code in the form: IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = N'IX_myindex') CREATE NONCLUSTERED INDEX [IX_myindex] ON [dbo].[mytable] ( [my_id] ASC )WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] GO How would you do this programmatically (ideally through Python)?

    Read the article

  • SQL server datetime column filter on certain date or range of dates

    - by MicMit
    There is an example for today here http://stackoverflow.com/questions/2583228/get-row-where-datetime-column-today-sql-server-noob I am primarily interested in 2008 only. For today it looked like SELECT (list of fields) FROM dbo.YourTable WHERE dateValue BETWEEN CAST(GETDATE() AS DATE) AND DATEADD(DAY, 1, CAST(GETDATE() AS DATE)) What literal value of date(s) or functions ( I need a format ) should I place there to make it work independent of local settings.

    Read the article

  • How optimize queries with fully qualified names in t-sql?

    - by tomaszs
    Whe I call: select * from Database.dbo.Table where NAME = 'cat' It takes: 200 ms And when I change database to Database in Management Studio and call it without fully qualified name it's much faster: select * from Table where NAME = 'cat' It takes: 17 ms Is there any way to make fully qualified queries faster without changing database?

    Read the article

  • Subsonic SELECT FROM msdb

    - by Lukasz Lysik
    Hi, I want to execute the following query using Subsonic: SELECT MAX([restore_date]) FROM [msdb].[dbo].[restorehistory] While the aggregate part is easy for me, the problem is with the name of the table. How should I force Subsonic to select from different database than default one.

    Read the article

  • minutes to time in sql server

    - by Luca Romagnoli
    i've created a function for convert minutes (smallint) in time (varchar(5)) like 58 - 00:58 set QUOTED_IDENTIFIER ON GO Create FUNCTION [dbo].[IntToMinutes] ( @m smallint ) RETURNS nvarchar(5) AS BEGIN DECLARE @c nvarchar(5) SET @c = CAST((@m / 60) as varchar(2)) + ':' + CAST((@m % 60) as varchar(2)) RETURN @c END The problem is when there are minutes < 10 in time like 9 the result of this function is 0:9 i want that the format is 00:09 how can i do that?

    Read the article

  • SQL Server with XML and selecting child nodes

    - by Zenox
    I have the following XML: <tests> <test>1</test> <test>2</test> <test>3</test> </tests> And I am trying the following query: CREATE PROCEDURE [dbo].[test] @Tests xml=null AS BEGIN SELECT doc.col.value('(test)[1]', 'nvarchar(50)') FROM @Tests.nodes('//tests') AS doc(col) END But it only returns me a value from the first What am I missing here?

    Read the article

  • How to bind a label inside a gridview to another table?

    - by Kolten
    I have a very standard Gridview, with Edit and Delete buttons auto-generated. It is bound to a tableadapter which is linked to my "RelationshipTypes" table. dbo.RelationshipTypes: ID, Name, OriginConfigTypeID, DestinationConfigTypeID I wish to use a label that will pull the name from the ConfigTypes table, using the "OriginConfigTypeID" and "DestinationTypeID" as the link. dbo.ConfigTypes: ID, Name My problem is, I can't automatically generate Edit and Delete buttons using an Inner Join in my dataset. Or can I? FOllowing is my code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" CssClass="TableList" DataKeyNames="ID" DataSourceID="dsRelationShipTypes1"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" Visible=False/> <asp:TemplateField HeaderText="Origin" SortExpression="OriginCIType_ID"> <EditItemTemplate> &nbsp;<asp:DropDownList Enabled=true ID="DropDownList2" runat="server" DataSourceID="dsCIType1" DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("OriginCIType_ID") %>'> </asp:DropDownList> </EditItemTemplate> <ItemTemplate> &nbsp; <asp:Label ID="Label2" runat="server" Text='<%# Bind("OriginCIType_ID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Name" SortExpression="Name"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Destination" SortExpression="DestinationCIType_ID"> <EditItemTemplate> <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="dsCIType1" DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("DestinationCIType_ID") %>'> </asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("DestinationCIType_ID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> So I did try to create my own edit and delete buttons, but kept receiving the error "cannot find update method" or something similar. Do I have to manually code the delete and update methods in my code-behind?

    Read the article

  • Doubt in stored procedure in asp.net

    - by Surya sasidhar
    hi, i am writing a sotreprocedure displaying month and year it is working but it is not coming in a order descending order can u help me my procedure like below... ALTER procedure [dbo].[audioblog_getarchivedates] as begin select DateName(Month,a.createddate) + ' ' + DateName(Year,a.createddate) as ArchiveDate from audio_blog a group by DateName(Month,a.createddate) + ' ' + DateName(Year,a.createddate) order by DateName(Month,a.createddate) + ' ' + DateName(Year,a.createddate) desc end result will come like this March 2010 January 2010 February 2010 but it is not in a order (desc) can u help me

    Read the article

  • Help with simple query - why isn't an index being used?

    - by Randy Minder
    I have the following query: SELECT MAX([LastModifiedTime]) FROM Workflow There are approximately 400M rows in the Workflow table. There is an index on the LastModifiedTime column as follows: CREATE NONCLUSTERED INDEX [IX_Workflow_LastModifiedTime] ON [dbo].[Workflow] ( [LastModifiedTime] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) The above query takes 1.5 minutes to execute. Why wouldn't SQL Server use the above index and simply retrieve the last row in the index to get the maximum value? Thanks.

    Read the article

  • SQL Server varchar to datetime

    - by Dezigo
    I have a field varchar(14) = 20090226115644 I need convert it to - 2009-02-26 11:56:44 (datetime format) My idea. use cast and convert.. but I always have errors. Conversion failed when converting datetime from character string. I made this, but don`t like it.. SELECT SUBSTRING(move,1,4) + '-' + SUBSTRING(move,5,2) + '-' + SUBSTRING(move,7,2) + ' ' + SUBSTRING(move,9,2) + ':' + SUBSTRING(move,11,2) + ':'+SUBSTRING(move,13,2) as new -- FROM [Test].[dbo].[container_events] where move IS not null Result :2009-02-26 11:56:44

    Read the article

  • Sql server Identity issue

    - by pranay
    I have query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName , CustomerAddress , CustomerEmail , CustomerPhone ) values ( ‘werw12e’ , ‘jkj12kj’ , ‘3212423sdf’ , ‘1212121' ) select @str_CustomerID= scope_identity() after execution it returns null in my parameter i want to get value of identity how can i do that

    Read the article

  • SQL Server, View using multiple select statements

    - by phil
    I've banging my head for hours, it seems simple enough, but here goes: I'd like to create a view using multiple select statements that outputs a Single record-set Example: CREATE VIEW dbo.TestDB AS SELECT X AS 'First' FROM The_Table WHERE The_Value = 'y' SELECT X AS 'Second' FROM The_Table WHERE The_Value = 'z' i wanted to output the following recordset: Column_1 | Column_2 'First' 'Second' any help would be greatly appreciated! -Thanks.

    Read the article

  • SQL 2000 xp_sendmail

    - by Steven
    Hi Guys, I have a trigger that sends an email once a value has been changed. It works when i make any amendments but when the users make the changes it fails. I have figured out the users havnt got permission to send mails in master.dbo.xp_sendmail The way the DB was originally setup wis shocking!! (each user has a network login rather than being part of a network group) Is there anyway i can allow a role in customerDb to access the xp_sendmail proc in the mater db? Thanks Sp

    Read the article

  • get index name within specific table name

    - by AmRoSH
    I need to check if this index not exist in specific table name not in all tables because this select statement select all indexes under this condition. IF NOT EXISTS (SELECT name from sysindexes WHERE name = 'IDX_InsuranceID') CREATE NONCLUSTERED INDEX [IDX_InsuranceID] ON [dbo].[QuoteInsurances] ( [InsuranceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY] GO Thanks,

    Read the article

  • What does ON [PRIMARY] mean?

    - by Icono123
    I'm creating an SQL setup script and I'm using someone else's script as an example. Here's an example of the script: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[be_Categories]( [CategoryID] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF_be_Categories_CategoryID] DEFAULT (newid()), [CategoryName] [nvarchar](50) NULL, [Description] [nvarchar](200) NULL, [ParentID] [uniqueidentifier] NULL, CONSTRAINT [PK_be_Categories] PRIMARY KEY CLUSTERED ( [CategoryID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO Does anyone know what the ON [PRIMARY] command does? Regards.

    Read the article

  • How do I remove database name from SQL Server generated script?

    - by bucha
    Anytime I use 'script table as' - 'Insert To' (or other command), the script generated automatically places the database name in the script. Such as: INSERT INTO [DatabaseName].[dbo].[tblToBeInserted] ... While not a huge problem to just delete it, it has slipped by a few times and the script breaks if run on a different server with a different database name but has the same schema. (Such as running on [DatabaseName.Test]) Is there an option I can change, or can I modify the output in any way to remove this?

    Read the article

  • XML XQUERY Problem with NTEXT data type

    - by johnfa
    Hello I want to use XQuery on a column of data type NTEXT (I have no choice!). I have tried converting the column to XML using CONVERT but it gives the error: Incorrect syntax near the keyword 'CONVERT'. Here's the query SELECT y.item.value('@UserID', 'varchar(50)') AS UnitID, y.item.value('@ListingID', 'varchar(100)') AS @ListingID FROM dbo.KB_XMod_Modules CROSS APPLY CONVERT(xml, instancedata).nodes('//instance') AS y(item) (instancedata is my column) Can anyone think of a work around for this ? Thanks

    Read the article

  • Using Table-Valued Parameters in SQL Server

    - by Jesse
    I work with stored procedures in SQL Server pretty frequently and have often found myself with a need to pass in a list of values at run-time. Quite often this list contains a set of ids on which the stored procedure needs to operate the size and contents of which are not known at design time. In the past I’ve taken the collection of ids (which are usually integers), converted them to a string representation where each value is separated by a comma and passed that string into a VARCHAR parameter of a stored procedure. The body of the stored procedure would then need to parse that string into a table variable which could be easily consumed with set-based logic within the rest of the stored procedure. This approach works pretty well but the VARCHAR variable has always felt like an un-wanted “middle man” in this scenario. Of course, I could use a BULK INSERT operation to load the list of ids into a temporary table that the stored procedure could use, but that approach seems heavy-handed in situations where the list of values is usually going to contain only a few dozen values. Fortunately SQL Server 2008 introduced the concept of table-valued parameters which effectively eliminates the need for the clumsy middle man VARCHAR parameter. Example: Customer Transaction Summary Report Let’s say we have a report that can summarize the the transactions that we’ve conducted with customers over a period of time. The report returns a pretty simple dataset containing one row per customer with some key metrics about how much business that customer has conducted over the date range for which the report is being run. Sometimes the report is run for a single customer, sometimes it’s run for all customers, and sometimes it’s run for a handful of customers (i.e. a salesman runs it for the customers that fall into his sales territory). This report can be invoked from a website on-demand, or it can be scheduled for periodic delivery to certain users via SQL Server Reporting Services. Because the report can be created from different places and the query to generate the report is complex it’s been packed into a stored procedure that accepts three parameters: @startDate – The beginning of the date range for which the report should be run. @endDate – The end of the date range for which the report should be run. @customerIds – The customer Ids for which the report should be run. Obviously, the @startDate and @endDate parameters are DATETIME variables. The @customerIds parameter, however, needs to contain a list of the identity values (primary key) from the Customers table representing the customers that were selected for this particular run of the report. In prior versions of SQL Server we might have made this parameter a VARCHAR variable, but with SQL Server 2008 we can make it into a table-valued parameter. Defining And Using The Table Type In order to use a table-valued parameter, we first need to tell SQL Server about what the table will look like. We do this by creating a user defined type. For the purposes of this stored procedure we need a very simple type to model a table variable with a single integer column. We can create a generic type called ‘IntegerListTableType’ like this: CREATE TYPE IntegerListTableType AS TABLE (Value INT NOT NULL) Once defined, we can use this new type to define the @customerIds parameter in the signature of our stored procedure. The parameter list for the stored procedure definition might look like: 1: CREATE PROCEDURE dbo.rpt_CustomerTransactionSummary 2: @starDate datetime, 3: @endDate datetime, 4: @customerIds IntegerListTableTableType READONLY   Note the ‘READONLY’ statement following the declaration of the @customerIds parameter. SQL Server requires any table-valued parameter be marked as ‘READONLY’ and no DML (INSERT/UPDATE/DELETE) statements can be performed on a table-valued parameter within the routine in which it’s used. Aside from the DML restriction, however, you can do pretty much anything with a table-valued parameter as you could with a normal TABLE variable. With the user defined type and stored procedure defined as above, we could invoke like this: 1: DECLARE @cusomterIdList IntegerListTableType 2: INSERT @customerIdList VALUES (1) 3: INSERT @customerIdList VALUES (2) 4: INSERT @customerIdList VALUES (3) 5:  6: EXEC dbo.rpt_CustomerTransationSummary 7: @startDate = '2012-05-01', 8: @endDate = '2012-06-01' 9: @customerIds = @customerIdList   Note that we can simply declare a variable of type ‘IntegerListTableType’ just like any other normal variable and insert values into it just like a TABLE variable. We could also populate the variable with a SELECT … INTO or INSERT … SELECT statement if desired. Using The Table-Valued Parameter With ADO .NET Invoking a stored procedure with a table-valued parameter from ADO .NET is as simple as building a DataTable and passing it in as the Value of a SqlParameter. Here’s some example code for how we would construct the SqlParameter for the @customerIds parameter in our stored procedure: 1: var customerIdsParameter = new SqlParameter(); 2: customerIdParameter.Direction = ParameterDirection.Input; 3: customerIdParameter.TypeName = "IntegerListTableType"; 4: customerIdParameter.Value = selectedCustomerIds.ToIntegerListDataTable("Value");   All we’re doing here is new’ing up an instance of SqlParameter, setting the pamameters direction, specifying the name of the User Defined Type that this parameter uses, and setting its value. We’re assuming here that we have an IEnumerable<int> variable called ‘selectedCustomerIds’ containing all of the customer Ids for which the report should be run. The ‘ToIntegerListDataTable’ method is an extension method of the IEnumerable<int> type that looks like this: 1: public static DataTable ToIntegerListDataTable(this IEnumerable<int> intValues, string columnName) 2: { 3: var intergerListDataTable = new DataTable(); 4: intergerListDataTable.Columns.Add(columnName); 5: foreach(var intValue in intValues) 6: { 7: var nextRow = intergerListDataTable.NewRow(); 8: nextRow[columnName] = intValue; 9: intergerListDataTable.Rows.Add(nextRow); 10: } 11:  12: return intergerListDataTable; 13: }   Since the ‘IntegerListTableType’ has a single int column called ‘Value’, we pass that in for the ‘columnName’ parameter to the extension method. The method creates a new single-columned DataTable using the provided column name then iterates over the items in the IEnumerable<int> instance adding one row for each value. We can then use this SqlParameter instance when invoking the stored procedure just like we would use any other parameter. Advanced Functionality Using passing a list of integers into a stored procedure is a very simple usage scenario for the table-valued parameters feature, but I’ve found that it covers the majority of situations where I’ve needed to pass a collection of data for use in a query at run-time. I should note that BULK INSERT feature still makes sense for passing large amounts of data to SQL Server for processing. MSDN seems to suggest that 1000 rows of data is the tipping point where the overhead of a BULK INSERT operation can pay dividends. I should also note here that table-valued parameters can be used to deal with more complex data structures than single-columned tables of integers. A User Defined Type that backs a table-valued parameter can use things like identities and computed columns. That said, using some of these more advanced features might require the use the SqlDataRecord and SqlMetaData classes instead of a simple DataTable. Erland Sommarskog has a great article on his website that describes when and how to use these classes for table-valued parameters. What About Reporting Services? Earlier in the post I referenced the fact that our example stored procedure would be called from both a web application and a SQL Server Reporting Services report. Unfortunately, using table-valued parameters from SSRS reports can be a bit tricky and warrants its own blog post which I’ll be putting together and posting sometime in the near future.

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >