Function Naming And Execution

Oct 17, 2006

Hi,

I am converting a database from Oracle to SQL-Server 2005 and in that context I needed to implement a function in the database. My database default uses the dbo schema and the function is there too. I define a function called "Translate" and wanted to use it like this :

SELECT translate(Phonenumber, '0123456789 ()+-', '0123456789') as PhonenumberFROM Customer

but what pussled my was that in order to make this work I had to prefix the translate method with "dbo." like this :

SELECT
dbo.translate(Phonenumber, '0123456789 ()+-', '0123456789') as Phonenumber
FROM
Customer

as all "objects" I'm using resides in the dbo schema - why must I prefiks only the function and not the table????

View 3 Replies


ADVERTISEMENT

Why Does A Function Call Require Two Part Naming?

Apr 3, 2008

Hi,
I just found out that when I create a user defined scalar function, I must call it using dbo.[myFunctionName]. Why won't it work w/out dbo? Why are stored procedures able to use omit dbo?

Also, what is dbo specifying? I'm very unfamiliar with sql server security. Is this the user, schema, role? What's a schema? lol. Thanks.

View 5 Replies View Related

The Worst Execution Plan For A Function

May 7, 2008

Hi,

I use a SQL Server 2000 and I am trying to use function instead of a ad hoc query because I REALLY have to do it, but some issues must be solved. SQL Server is using a optimal execution plan when I run query and the worst execution plan for function.

Here are the informations you might need to help me:

Table DDL



Code SnippetCREATE TABLE [IRES] (
[CPF_CNPJ] [varchar] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TIPO] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[IMPEDIMENTO] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[GRAU] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DT_ULT_OCOR] [datetime] NULL
) ON [PRIMARY]
GO





indexes
sp_helpindex ires



Code Snippet
name description keys
IRES_CPF clustered located on PRIMARY CPF_CNPJ
IRES_IMPED nonclustered located on PRIMARY IMPEDIMENTO





PERFORMANCE INFO

QUERY - it takes 2s to run and server makes an index seek on IRES_CPMF index




Code Snippet
select 'query ad-hoc',*
from IRES
where CPF_CNPJ = '000002230'
and TIPO = 'F'

EXECUTION PLAN
Clustered Index Seek(OBJECT:([bmcires].[dbo].[IRES].[IRES_CPF]), SEEK:([IRES].[CPF_CNPJ]='000002230'), WHERE:([IRES].[TIPO]='F') ORDERED FORWARD)


FUNCTION - it takes 20s to run and server makes a index scan on IRES_IMPED index!!!!




Code Snippet
CREATE FUNCTION fn_ires_crivo
( @cpfcnpj nvarchar(9) )
RETURNS table
AS
RETURN (
SELECT CPF_CNPJ,
TIPO,
IMPEDIMENTO,
GRAU,
DT_ULT_OCOR
FROM dbo.ires WITH (INDEX (IRES_CPF) NOLOCK)
WHERE
CPF_CNPJ = @cpfcnpj
and TIPO = 'F'
)
go


select cpf_cnpj
from fn_ires_crivo('000000029')

EXECUTION PLAN
|--Filter(WHERE:([IRES].[TIPO]='F'))
|--Bookmark Lookup(BOOKMARK:([Bmk1000]), OBJECT:([bmcires].[dbo].[IRES]))
|--Parallelism(Gather Streams)
|--Index Scan(OBJECT:([bmcires].[dbo].[IRES].[IRES_IMPED]), WHERE:(Convert([IRES].[CPF_CNPJ])='000000029'))


View 7 Replies View Related

Performance Of Table-valued Function And Execution Plan

Mar 31, 2008

I am using SQL2005 EE with SP1. The server OS is windows 2K3 sp2

I have a table-valued function (E.g. findAllCustomer(Name varchar(100), gender varchar(1)) to join some tables and find out the result set base the the input parameters.

I have created indexes for the related joinning tables.

I would like to check the performance of a table-valued function and optimize the indexing columns by the execution plan.

I found the graphic explanation only show 1 icon to represent the function performance. I cannot find any further detail of the function. (E.g. using which index in joinning)

If I change the function to stored procedure, I can know whether the T-SQL is using index seek or table scan. I also found the stored procedure version subtree cost is much grether that the table-valued function

I would like to know any configureation in management studio can give more inform for the function performance?

Thanks


View 3 Replies View Related

Static Variables In A SQLCLR Stored Proc Seem To Get Reused From Execution To Execution Of The Sp

Aug 23, 2007

after moving off VS debugger and into management studio to exercise our SQLCLR sp, we notice that the 2nd execution gets an error suggesting that our static SqlCommand object is getting reused from the 1st execution (of the sp under mgt studio). If this is expected behavior, we have no problem limiting our statics to only completely reusable objects but would first like to know if this is expected? Is the fact that debugger doesnt show this behavior also expected?

View 4 Replies View Related

Execution Plans &<&> Proportionate Execution Times

Dec 7, 2005

Hi I am slowly getting to grips with SQL Server. As a part of this, I have been attempting to work on producing more efficient queries. This post is regarding what appears to be a discrepancy between the SQL Server execution plan and the actual time taken by a query to run. My brief is to produce an attendance system for an education establishment (I presume you know I'm not an A-Level student completing a project :p ). Circa 1.5m rows per annum, testing with ~3m rows currently. College_Year could strictly be inferred from the AttDateTime however it is included as a field because it a part of just about every PK this table is ever likely to be linked to. Indexes are not fully optimised yet. Table:CREATE TABLE [dbo].[AttendanceDets] ([College_Year] [smallint] NOT NULL ,[Group_Code] [char] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,[Student_ID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,[Session_Date] [datetime] NOT NULL ,[Start_Time] [datetime] NOT NULL ,[Att_Code] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY]GO CREATE CLUSTERED INDEX [IX_AltPK_Clust_AttendanceDets] ON [dbo].[AttendanceDets]([College_Year], [Group_Code], [Student_ID], [Session_Date], [Att_Code]) ON [PRIMARY]GO CREATE INDEX [All] ON [dbo].[AttendanceDets]([College_Year], [Group_Code], [Student_ID], [Session_Date], [Start_Time], [Att_Code]) ON [PRIMARY]GO CREATE INDEX [IX_AttendanceDets] ON [dbo].[AttendanceDets]([Att_Code]) ON [PRIMARY]GOALL inserts are via an overnight sproc - data comes from a third party system. Group_Code is 12 chars (no more no less), student_ID 8 chars (no more no less). I have created a simple sproc. I am using this as a benchmark against which I am testing my options. I appreciate that this sproc is an inefficient jack of all trades - it has been designed as such so I can compare its performance to more specific sprocs and possibly some dynamic SQL. Sproc:CREATE PROCEDURE [dbo].[CAMsp_Att] @College_Year AS SmallInt,@Student_ID AS VarChar(8) = '________', @Group_Code AS VarChar(12) = '____________', @Start_Date AS DateTime = '1950/01/01', @End_Date as DateTime = '2020/01/01', @Att_Code AS VarChar(1) = '_' AS IF @Start_Date = '1950/01/01'SET @Start_Date = CAST(CAST(@College_Year AS Char(4)) + '/08/31' AS DateTime) IF @End_Date = '2020/01/01'SET @End_Date = CAST(CAST(@College_Year +1 AS Char(4)) + '/07/31' AS DateTime) SELECT College_Year, Group_Code, Student_ID, Session_Date, Start_Time, Att_Code FROM dbo.AttendanceDets WHERE College_Year = @College_YearAND Group_Code LIKE @Group_CodeAND Student_ID LIKE @Student_IDAND Session_Date <= @End_DateAND Session_Date >=@Start_DateAND Att_Code LIKE @Att_CodeGOMy confusion lies with running the below script with Show Execution Plan:--SET SHOWPLAN_TEXT ON--Go DECLARE @Time as DateTime Set @Time = GetDate() select College_Year, group_code, Student_ID, Session_Date, Start_Time, Att_Code from attendanceDetswhere College_Year = 2005 AND group_code LIKE '____________' AND Student_ID LIKE '________'AND Session_Date <= '2005-11-16' AND Session_Date >= '2005-11-16' AND Att_Code LIKE '_' Print 'First query took: ' + CAST(DATEDIFF(ms, @Time, GETDATE()) AS VarCHar(5)) + ' milli-Seconds' Set @Time = GetDate() EXEC CAMsp_Att @College_Year = 2005, @Start_Date = '2005-11-16', @End_Date = '2005-11-16' Print 'Second query took: ' + CAST(DATEDIFF(ms, @Time, GETDATE()) AS VarCHar(5)) + ' milli-Seconds'GO --SET SHOWPLAN_TEXT OFF--GOThe execution plan for the first query appears miles more costly than the sproc yet it is effectively the same query with no parameters. However, my understanding is the cached plan substitutes literals for parameters anyway. In any case - the first query cost is listed as 99.52% of the batch, the sproc 0.48% (comparing the IO, cpu costs etc support this). BUT the text output is:(10639 row(s) affected) First query took: 596 milli-Seconds (10639 row(s) affected) Second query took: 2856 milli-SecondsI appreciate that logical and physical performance are not one and the same but can why is there such a huge discrepancy between the two? They are tested on a dedicated test server, and repeated running and switching the order of the queries elicits the same results. Sample data can be provided if requested but I assumed it would not shed much light. BTW - I know that additional indexes can bring the plans and execution time closer together - my question is more about the concept. If you've made it this far - many thanks.If you can enlighten me - infinite thanks.

View 10 Replies View Related

Execution Procedure Stored During Execution Of The Report .

Aug 3, 2007



Hello :

How to execute a procedure stored during execution of the report, that is before the poster the data.

Thnak you.

View 4 Replies View Related

FK Naming

Sep 28, 2007

Hello, I have 2 tables: Articles and Users. These 2 tables are related by AuthorId (FK) in Articles and UserId (PK) in Users. My question is: should the use the same name for the 2 keys, i.e., UserId? Or it is normal to use AuthorId in Articles table and UserId in Users table. This makes more sense. Just a naming question. Thanks, Miguel  

View 5 Replies View Related

DB Column Naming

Jun 18, 2006

What does everyone think of this method?I have a ton of tables like User, Project etc. I use the SAME column names for each table. For an example, ID, Name, Status etc instead of UserID etc.Only for relationship naming will I use UserID.The reason I do this is from a OOP perspective.My dad often said that a table was a entitiy of an object and each record in the table was a instance of that object.

View 2 Replies View Related

Naming Problem

May 3, 2005

I have a function which is named like this:

CREATE FUNCTION [GEEKASPNET.Split]

How can I use it in my stored procedure:

UPDATE Tasks SET Status = 0
WHERE TaskID IN (SELECT CONVERT(int, Value) FROM [GEEKASPNET].Split(@Tasks,","))

This does not work and gives me that "unreconized function GeekASPNET.Split

View 5 Replies View Related

DTS: Re-Naming Package

Jan 2, 2001

I am using SQL Server 7 w/ SP2. This may seem silly, but I'm trying to re-name a DTS local package -- so far without success. Surely there's a way to do this. Also, where is DTS info stored? That is, how does SQL Server store package names and other details? Thanks!

View 1 Replies View Related

Re-naming A DTS Package

Oct 12, 2000

Does anyone know if there is someway to rename a DTS package? Or can I go into the msdb database
and delete the old name?

Thanks for your help.

Dianne

View 3 Replies View Related

Naming Conventions

Jan 31, 2005

Most of the programming I do is in Access. I like to use naming conventions for all my tables, queries, etc. I am now moving several databases to SQL Server. Does anyone know of a good resource for naming convetions in SQL Server. Website, book?

View 2 Replies View Related

Naming Convention

Aug 21, 2006

Hi all,
I wanted to ask for the naming conventions in SQL SERVER.as in case of pl/sql server we have ..name_of_package.name_of_procedure thats how we call the procedures i.e. owner of schema then name of package n then procedure name.....i want to ask you all how is it done in SQL SERVER..please try to reply as soon as possible,
i will b waiting for the replies,
regards

View 3 Replies View Related

Naming Conventions

Mar 8, 2006

In our database tables are generated like
EMP_MASTER
DEPT_MASTER

like that. when we generate classes from database the class names are looking like

EmpMaster
DeptMaster

but for my classes that Master suffix is not required.
please solve my problem.

Thanks and Regards,
guru

View 4 Replies View Related

Naming Convention

May 8, 2006

Would like to know what naming convention you folks use.

What I need specifically is column naming conventions.

For instance, I have a table called 'lst_as400_srvr'. We could go with the vigorous:

CREATE TABLE lst_as400_srvr
(
as400_srvr_idintNOT NULLIDENTITY,
as400_srvr_namevarchar(128)NOT NULL,
as400_srvr_is_activebitNOT NULLDEFAULT 1
)

Or, I could loosen the rules a bit and go with:

CREATE TABLE lst_as400_srvr
(
idintNOT NULLIDENTITY,
namevarchar(128)NOT NULL,
is_activebitNOT NULLDEFAULT 1
)

I would lean towards the vigorous because it would be very obvious what data is being referenced by the name. In the loosened version, I could very easily have many tables with a 'id' column or a 'is_active' column.

Inversely, I would lean towards the loosened version because the names are a lot shorter and, thus, easier / faster to type.

I figure, if I'm going to learn a new standard, now's a good time to do so.

So, thoughts? Appreciate the help folks. :)

View 5 Replies View Related

SQL Database Naming

Jul 18, 2007

I'm creating a new database for an application that I wish to sell in the future. When we sell it the client will have the option to host is or have us host it. I want to create a name for the database that doesn't describe what the product is. I also want to be able to create new databases if we host it and those names be of a similar convention or subject. I was thinking each would be a Greek god, galaxy names or something along those lines. Does anyone have any suggestions?

Thanks,
Ryan

View 7 Replies View Related

Naming Conventions

May 3, 2007

I'm coming from a MS Access background and so I'm very used to andcomfortable with the hungarian (Leszynski et al) naming conventions.However, I'm getting started into my first SQL Server Database andreally want to use the appropriate up to date standard namingconvention (ISO compliant).I think I have the general idea from raking though countlessconflicting sites and posts, but I'm a bit stuck on what to doregarding pk / fk namingFor example, in my MS Access world I would have two tables:tblOrders=======strOrderIDintCustomerIDdtOrderDate....tblCustomers==========intCustomerIDstrCustomerName....So what would the appropriate and most up-to-date and standard namingbe for SQL Server? My Guess:Orders=====Ord_Order_ID_PkOrd_Customer_ID_FkOrd_Order_Date....Customers========Cus_Customer_ID_PkCus_Customer_Name....How close (or far) am I from "Celko Proof" naming here?All help gratefully accepted!

View 9 Replies View Related

DTS Naming In Jobs

Oct 4, 2007

When I schedule a DTS package as a Job and then look in the job step detail I am presented with the following line.

DTSRun /~Z0x3A2210EB05CE1F9968C82E............etc

This number means nothing to me and I presume it might be encoded or encrypted.
If I wanted to be sure that this code actually relates to the correct DTS package how can I check.

Is there a specific table that will hold that code that will relate it to the DTS package??

Cheers
Tom

View 1 Replies View Related

Naming Of Reports

Dec 27, 2007

I use data driven subscriptiosn to deliver the same report to 6 different customers. But each customer can see only his data. Reports are saved in a shared folder in xl version. Reports are saved like report_1,report_2 etc. Is there anyother way to name these reports without letting customer to change the name?

Thanks

View 4 Replies View Related

Naming Convention

Feb 26, 2007

Sorry if this seems trivial, but is it allowed to add hyphens in a physical server name?
eg: PC-01


Will this cause any errors (when connecting, etc)
Thanx.

View 1 Replies View Related

Naming Convention

Dec 5, 2007



Is there any standard naming convention for SQL Server that microsoft suggest it?
the same as naming guidlines in MSDN for designing libararies in .Net Framework.

View 4 Replies View Related

Sql Table Naming Convention

Dec 20, 2003

I have to build a table Physicalcharacterics in sql.

Convention for naming a table

Would I name this table in sql server
tbl_User_PhysicalCharacterics.
My main parent table is tbl_User.


Is that too long of a name.

View 2 Replies View Related

SqlServer Naming Conventions

Nov 18, 2005

I noticed that a lot of my stuff is getting named dbo.XXXXXXX.  Why is it happening and what does this mean?

View 4 Replies View Related

Naming Of Relationship Table

Jun 10, 2006

We have two tables. Users and Projects and there is a many-to-many relationship.Ex. A user can be assigned into multiple projects.For the relationship table, should the table name be UserProjects or ProjectUsers?Also should it be singular or plural? (ex. UsersProjects or ProjectsUsers)?

View 2 Replies View Related

SQL Table Naming Problem :(

Mar 31, 2000

Hi, can anyone help me with this strange problem?

I am trying to name a new SQL table, but I keep receiving a message that a table with this name already exists in the database. However, when I try to run a SELECT statement using that table, the error msg tells me the object does not exist,and it is not in the combobox of existing tables that can be added to a diagram.

Any clues would be appreciated, thanks !

View 2 Replies View Related

Dynamic Table Naming From Sp

Sep 22, 2000

Does anyone know if it is possible to create dynamically named tables from within a stored procedure? The goal is to append a unique identifier on the end of an otherwise static table name to allow for multiple incarnations of the table to exist concurrently while not interfering with each other. For example, we would like to create and use a temp table that is suffixed with a login name to or a timestamp to make it unique.

Is this possible?

View 6 Replies View Related

Naming Standards For SQL Objects

Sep 2, 1998

I was wondering if there are generally accpeted naming standards for SQL Server ojbects (tables, store procedeures, triggers, views etc.) that might be available somewhere on the WEB. I was also wondering if most DBA`s prefix the object names like "sp_" or suffix the object like "Customer_T"? Any opinions?

View 1 Replies View Related

Cluster: Instance Naming

Sep 3, 2007

Hi all

SQL Server 2005 cluster. Active-Active. We want to create two instances. The two nodes are named:

mike-940-01
mike-940-02

I read somewhere that there can only be ONE default instance in a 2005 cluster. So I interpret that as meaning that I can only have one instance named after a virtual server (example: mike-940-03) and the other instance has to be a slashed instance (example: mike-940-03/instance1). But what if I create another virtual server (example: mike-940-04). Can I install a default instance in that server? Can someone help me clarify this?

Also, if I'm using all slashed instance names, then what does it choose as the base name before the slash? In other words, what decides which virtual server name is used? Is it the management node? Is it one of the nodes?

My objective is to keep consistency in the naming on the cluster. If I have to use slashed instances, then I want all sql server instances to have a slash.

Sorry about the confusing explanation, but that's probably a symptom of MY confusion.

Thanks!

View 4 Replies View Related

Naming Based On A Subquery

Jun 13, 2008

I'd like to name an output field based on the result of a subquery look up. This is the idea:

select colname1 as (select name from tableofnames where nameid=1)

..but that doesn't work. What would?

View 4 Replies View Related

Naming Calcualted Columns

Jun 19, 2006

I have several calcuatled columns in a table (see below) that I have been work with. First can I assign a proper naming decision to the columns? How can I reference these columns in other tables?

For example how can I assign names to the columns listed below?

select date, ((abc * .05)+ efgh * .05), (((efgh * .475) + (abc * .475) + (123gross * .05)))
from table
where date = '2006-03-31

Thanks

View 15 Replies View Related

Universal Naming Convention.

Aug 21, 2006

how can i find the servername and sharefolder on my computer to access a file?

for the server name i used the ip aand sharefolder i used computer description.
i think its not right cause its not working.

View 18 Replies View Related

Where Can I Get I Guide On Conventions For Naming

Jun 12, 2007

Where can I get I guide on conventions for naming, stored procedures, tables, user functions ? that I can implement in my work

View 6 Replies View Related







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