Alias with field name in MS SQL Server

Is it possible that we can define alias for field name in MS SQL Server?
For example:
mytable : Id, Name, Value
Could we define "AnotherName" for "Name" field that we can call it from sql
SELECT anothername from mytable

I don't know if you can "permanently" create an alias
without a view or something like that but if you just
want another name when you execute a select do this:
Select name as another name from tableAt least in some databases the syntax for that can vary slightly. So the following might be needed....
Select name as 'another name' from table

Similar Messages

  • Retrieve available server names for MS SQL server

    hello
    Can somebody tell me how I can retrieve available server names for MS SQL server.
    When MS SQL server loads it asks for server name to connect but on the same time has a combobox with the available server names(instace+database name). How can I provide the same functionality in my application?
    Thank you in advance.

    It isn't going to be as simple as just the name.
    There are also different ways to connect and probably other parameters as well.
    SQL Server Enterprise Manager probably uses a discovery protocol. It probably sends one or more messages requesting information and those servers that want to respond.
    Note that none of that has anything to do with JDBC and discovering how it does that probably isn't easy. A packet sniffer might help.

  • How uninstall WSUS server role from Windows Server 2008 R2 with database hosted on remote SQL server?

    Hello, 
    I'm looking to uninstall the WSUS server role 3.0 from Windows Server 2008 R2 SP1. The thing is the database is hosted on a remote MS SQL server. I want to remove the database as well. I would like help for figuring out what I need to do to completely remove
    WSUS and its database.
    Any kind of help is appreciated! Thanks  

    Hi,
    WSUS offers limited support for running database software on a computer that is separate from the computer where the rest of WSUS is installed. This section offers step-by-step
    instructions for how to install WSUS in this configuration.
    If you meet the uninstall issue with the normal uninstall, please post the detail information for us but if you just want to manage the WSUS related SQL data, you can refer
    the following KB then delete corresponding database.
    In the general procedure, you will create the related WSUS database as below::
    Run WSUS Setup from the command line, using the SQLINSTANCE_NAME=servername\instancename command-line option, where servername is the name of the remote computer, and instancename
    is the name of the SQL Server instance that you will use for WSUS.
    More information:
    Choose the Database Used for WSUS 3.0
    http://technet.microsoft.com/en-us/library/cc708452(v=ws.10).aspx
    Appendix B: Configure Remote SQL
    http://technet.microsoft.com/en-us/library/cc708595(v=ws.10).aspx
    Hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to get error's field name when execute sql error

    I want to get the error's field name when execute sql error,but SQLException is not provide corresponding function to get it.
    How can I do for it?

    user523110,
    I believe the "unique constraint" error message displays the name of the constraint, not the column name, as you have posted.
    As far as I know, the only way to extract the column(s) would be to query the data dictionary using the constraint name provided in the error message.
    Also, as far as I know, there is nothing in the JDBC API that can return the names of the columns associated with a given unique constraint.
    Good Luck,
    Avi.

  • Trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.

    I am trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.
    It verifies the connection and then throws the error:
    The request to add or remove features on the specified server failed. The operation cannot be completed, because the server you specified requires a restart.
    WSUS Server : Windows Server 2012 R2
    Remote SQL Server: 2012 SP1 CU7 hosted on Windows Server 2012 R2
    Please let me know if anyone has experienced this issue.

    We were trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.
    It verifies the connection and then throws the error:
    The request to add or remove features on the specified server failed. The operation cannot be completed, because the server you specified requires a restart.
    Same error even after rebooting the server multiple times.
    WSUS Server : Windows Server Standard2012 R2
    Remote SQL Server: Windows Server 2012 SP1 CU7 hosted on Windows Server 2012 R2
    Event ID 7000:
    The Windows Internal Database service failed to start due to the following error:
    The service did not start due to a logon failure.
    Event ID 7041
    The MSSQL$MICROSOFT##WID service was unable to log on as NT SERVICE\MSSQL$MICROSOFT##WID with the currently configured password due to the following error:
    Logon failure: the user has not been granted the requested logon type at this computer.
    Service: MSSQL$MICROSOFT##WID
    Domain and account: NT SERVICE\MSSQL$MICROSOFT##WID
    This service account does not have the required user right "Log on as a service."
    User Action
    Assign "Log on as a service" to the service account on this computer. You can use Local Security Settings (Secpol.msc) to do this. If this computer is a node in a cluster, check that this user
    right is assigned to the Cluster service account on all nodes in the cluster.
    If you have already assigned this user right to the service account, and the user right appears to be removed, check with your domain administrator to find out if a Group Policy object associated
    with this node might be removing the right.
    I found following article:
    "MSSQL$MICROSOFT##WID service was unable to log on as NT SERVICE\MSSQL$MICROSOFT##WID" error when you install WID in Windows Server 2012
    http://support.microsoft.com/kb/2832204/en-us
    To work around the issue, use one of the following methods:
    Assign the Log on as a service user right to NT SERVICE\ALL SERVICES in the GPO that defines the user right.
    Exclude the computer from the GPO that defines the user right.
    We moved the SCCM server to OU where no policies were getting applied and then applied the new GPO to that OU. Restarted the server and we were able to install WSUS role.
    Regards
    PR

  • Creating a view on KONA & KONH -  Failed with 'Field name DATAB not unique'

    Hi all,
        I am creating a view on KONA (Rebate Agreement) & KONH (Conditions Header) tables. The link is KONA-KNUMA = KONH-KNUMA_AG.
       The field 'DATAB' exists in both tables and I have included those two fields under 'View Fields' . When I tried to activate the View, it fails with 'Field name DATAB not unique'.
       The following is the complete error message:
    Message no. MC060
    Diagnosis
    When you define aggregates (views, lock objects or matchcode objects), you can assign the aggregate fields your own names (the system assigns names to the basic fields automatically). These names must be unique.
    System response
    The system has established that the names assigned to the aggregate fields in an aggregate definition are not unique and issues an error message.
    Procedure
    Assign unique names to the aggregate fields in question.
       Why I am not able to create the view after including a field that EXISTS in two tables, PLEASE ?
    Thanks,
    Venkat.

    Hi,
    you can include both fields (but what for??); most likely KNUMH will also complain after fixing DATAB (just a guess...).
    You can include both fields if you name them differently (different aliases):
    In the view fields tab, enter two different names in the column "view field".
    this will work.
    hope this helps...
    Olivier.
    Message was edited by:
            Olivier Cora

  • What is the best way to deal with memory leak issue in sql server 2008 R2

    What is the best way to deal with memory leak issue in sql server 2008 R2.

    What is the best way to deal with memory leak issue in sql server 2008 R2.
    I have heard of memory leak in OS that too because of some external application or rouge drivers SQL server 2008 R2 if patched to latest SP and CU ( may be if required) does not leaks memory.
    Are you in opinion that since SQL is taking lot of memory and then not releasing it is a memory leak.If so this is not a memory leak but default behavior .You need to set proper value for max server memory in sp_configure to limit buffer pool usage.However
    sql can take more memory from outside buffer pool if linked server ,CLR,extended stored procs XML are heavily utilized
    Any specific issue you are facing
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Do we need to format data and log files with 64k cluster size for sql server 2012?

    Do we need to format data and log files with 64k cluster size for sql server 2012?
    Does this best practice still applies to sql server 2012 & 2014?

    Yes.  The extent size of SQL Server data files, and the max log block size have not changed with the new versions, so the guidance should remain the same.
    Microsoft SQL Server Storage Engine PM

  • Problem using alias field names in a sql query

    Hello,
    I have a question regarding a simple Oracle database SQL query writeup:
    In the following (badly written but properly working) SQL query:
    Query 1:
    select
    soe.field1,
    (soe.field2 + soe.field3) as field4,
    (soe.field5 - (soe.field2 + soe.field3)) as field6,
    (select comp.parValue*soe.field7
    from
    CompTable comp) as parValue,
    (select soe.field8 - (comp.parValue*soe.field7+ soe.field9)
    from
    CompTable comp) as field10
    from
    SomeTable soe
    PROBLEM 1:
    I am re writing the code (soe.field2 + soe.field3) to get the alias field4 or column name field4 that I have created on the fly in the previously for use with the following fields. Can't I rewrite the query as follows. There is something simple missing!
    Query 2:
    select
    soe.field1,
    (soe.field2 + soe.field3) as field4,
    soe.field5 - field4 as field6, <<< field4 does not work here
    (select
    comp.parValue*soe.field7
    from
    CompTable comp) as parValue,
    (select
    soe.field8 - (comp.parValue*soe.field7+ soe.field9)
    from
    CompTable comp) as field10
    from
    SomeTable soe
    PROBLEM 2:
    Similar to the above problem, I was thinking to get a field parValue out of the CompTable table and re-use many times rather than the code shown in Query 1:
    Query 3:
    select
    soe.field1,
    (soe.field2 + soe.field3) as field4,
    soe.field5 - field4 as field6,
    soe.field7* (select comp.parValue from CompTable comp) as parValue1,
    soe.field8 - (parValue1*soe.field7+ soe.field9) as field10      <<<< parvalue1 does not work here
    parValue1*soe.field9 as TaxCondition               <<<< parvalue1 does not work here
    from
    SomeTable soe
    See that the query becomes so simple, but the above query does not work. There is something fundamentally wrong in my usage of the alias field names in creating other fields. The Query1 seems to be the only working option but its very slow as I am redoing and re-writing the whole code again and again to get the parValue field out of the CompTable table for use to create many other fields.
    I will appreciate if you can guide me in the right direction on this issue.
    Thanks and Regards
    Rama

    SELECT tmp.contract_no, tmp.Actual, tmp.Actual - tmp.NbHours
    FROM ( SELECT t.contract_no, sum(l.hrs) AS Actual, (c.labour_hours * c.labour_progress_per) / 100 AS NbHours
    FROM TASK_DELEGATION t
    INNER JOIN COST_CODE c
    ON t.cost_code = c.cost_code AND t.contract_no = c.contract_no AND t.is_inactive=0
    INNER JOIN Labour.dbo.LABOURALLOT l
    ON l.contractNo = c.contract_no AND l.costcode = c.cost_code AND l.pm = 'N'
    GROUP BY t.contract_no, c.labour_hours, c.labour_progress_per
    ) tmp

  • Creating New db(with new name) with the old db backup sql server 2008

    Friends..
    version: Sql Server 2008
    I have a database in a name college1 (more than 200 tables and view etc...)
    i want to create a new db with all the structures including the data of the above db college1 with a new name college2
    so...i finished the step 1 successfully.. what are the other steps i have to do...like validating the invalid objects. etc....
    Step 1:
    RESTORE DATABASE college2 FROM DISK = 'D:\DailyDBbackup\college1.bak'
      WITH replace,
      move 'college2 ' TO 'D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\college2 .mdf',
      move  'college2 _log' TO 'D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\college2 _log.ldf';
    step 2: ?
    Step 3: ?
    thanks...

    but...when i type
    use college1
    select * from (it will display all tables under the above db)
    but when i do..
    use college2
    select * from (only system tables are displaying..)
    Did restore completed successfully ? If yes Expand database , can you see tables in the new database you restored ?. Sometimes when you type incorrect word which does not matches anything you wont get help from intellicense you should not be worried about this
    if tables are there in new database college 2
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Isse with using Grouping Sets in SQL Server 2008 R2

    Hi,
    I created a query in SQL Server 2012 using grouping sets that works fine.  When I try to use the same query in SQL Server 2008 I get an error ("Inccorrect syntax near SETS").
    I researched using grouping sets in 2008 and didn't see any issue with my query.  What is different in grouping sets 2008 vs 2012?
    SELECT tl.ClientRegionCd as [Client Region Code] , tl.ClientRegionDesc as [Region Name], count(tl.CompleteICN) as [Trauma Letters Sent]
    from TORT_Trauma_Letters tl
    Where CONVERT(VARCHAR(26), tl.SecondNoticeSent, 23) between '2014-06-12' and '2014-06-12'
    GROUP BY GROUPING SETS((tl.ClientRegionCd, tl.ClientRegionDesc), ())
    Stacie

    Check this blog post as how to deal with date ranges
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx
    For your result you can simply achieve your result with UNION ALL, e.g.
    select Client, Region, Letters
    from myTable 
    UNION ALL
    select NULL, NULL, SUM(letters) as Letters
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • CR with VS 2003 Oracle vs SQL Server 2005

    VS2003
    Windows XP
    All Crystal Reports designed using "push" model (Seting the Report Document's SetDataSource property using a single table dataset)
    I have a large VS2003 application (90+ Crystal Reports) using an Oracle database.  The client wants to switch to SQL Server 2005.  The application works with SQL Server "as is" except for the Crystal Reports.  A query engine error is generated.  The tables/views are quite simple using only integers, decimals, char and varchar columns, no datetime columns.   The dataset's  Name and datatable's Name are the same, the only difference is the data provider used.  Microsoft's Oracle Data provider vs Microsoft's SQL Server Data provider. Any thoughts? Any workarounds?.
    I am in the process of converting the application to VS2008 and the problem does not exist in the VS2008 version.  Crystal Reports converted from VS2003 to VS2008 work with either database/data provider.,
    Edit: It appears that Oracle does not differentiate between datatypes decimal and int32.  Any thoughts. (Not the problem)
    Edited by: spooky102 on Aug 17, 2009 6:40 PM
    Edited by: spooky102 on Aug 17, 2009 6:42 PM
    Edited by: spooky102 on Aug 17, 2009 7:31 PM

    An assumption here is that your .NET 2003 app is using the bundled version of CR(?) - version 9.1. If that is the case, make sure you have updated your install with SP1:
    https://smpdl.sap-ag.de/~sapidp/012002523100009301312009E/crnet11win_en.zip
    Next, see if this blog will help you in troubleshooting the issue:
    /people/ludek.uher/blog/2009/03/02/troubleshooting-issues-with-vs-net-datasets-and-crystal-reports
    re:
    It appears that Oracle does not differentiate between data types decimal and int32.
    Not sure how this relates to Crystal Reports as such? But let's work on one issue per thread. If you want to work the data type issue more, please create a new thread. Otherwise, these things get too messy...
    Ludek

  • Execute SQL Task with Parameter - from DB2 to SQL Server

    I am pulling data from DB2 to SQL Server.
    1st Execute SQL task runs the following against DB2:
    SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
    FROM SYSIBM.SYSDUMMY1;
    I'm storing it as a Result Set.
    Next I have a Data Flow Task.  This pulls data from DB2 where the date matches the parameter.
    FROM SCHEMA.TABLE t
    WHERE DATE_TIME_COLUMN= ?
    This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
    The problem is, I want to remove existing data for the same date in the SQL table.  IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table.  The main use is for re-runs.
    So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= ?
    The package fails at the new Execute SQL Task with the following error message:
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
    SBO.dbo.tblHE_MSP_FEE_BUCKETS
    WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
    correctly.
    Task failed: Execute SQL Task
    SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
    The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
    I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
    Any suggestions on how to make this work??
    Thanks,
    -Al H

    Parameter name is unrecognized
    is the key, how come DB2 is related if it runs against SQL Server
    What I think is happening you do not use the OLEDB connection to SQL Server.
    Likewise, if it is ADO then the query needs to be
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= @MyDate
    Arthur My Blog

  • Alias a field name in a join query

    I have a database with spaces in the field names (not my fault).
    I am having a problem with the query because one of the fileds I am joining on has a space in its name. See bolded text.
    SELECT *
    FROM employee_passwords
    INNER JOIN employee_general_info
    ON employee_passwords.Employee_ID=employees.[Employee ID]
    WHERE username = '#username#' AND password = '#password#'  
    So I get this error message
    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'employees.Employee ID'.
    Is there a way to alias the employees.[Employee ID] field?

    Should be
    ON employee_passwords.Employee_ID=employee_general_info.[Employee ID]

  • Problem in EOImpl.doDML() ,with Identity column in MS SQL server.

    Hello,
    I'm using JDeveloper 11.1.1.4.0
    My application is working with MS SQL Server.
    One of the tables in the database has its PK as Identity column.
    EO is created with the corresponding attribute as Primary Key.
    Upon calling doDML() in EOImpl, it generates an insert statement and attempts to insert in the PK field as well. MS SQL does not allow insertion in PK field and throws exception.
    I tried setting some configuration on EO PK attribute, but in vein. Also there is no other 'unique' column in table that can be setup as PK in EO.
    Appreciate your suggestions.
    Regards,
    Amar

    i think better to Oracle datbase as I am afraid of that Oracle won't be able to see your problem against sql server due to sql server is not their product!

Maybe you are looking for

  • Cancelled Infinity. Wifi signal did not reach rest...

    Short synopsis:   Before buying Infinity, try your current wifi hub plugged into your master socket, and see if your wifi signal can still reach the rest of the house.  If your master is at the wrong end of the house to your computers, like me, then

  • Live View not rendering in CS5

    I have tried to use Live View to test my php code and have literally only put a line of php code in the body of my html which is <?php echo "This date is generated by php code "; echo date ('d F, Y'); ?> Live View is processing but does not render th

  • Toplink JPA Calling Oracle Function Return sys_refcursor

    I have a function which return sys_refcursor and I am trying to call this using JPA(1.0) @NamedNativeQuery( name = "getEmpsByDeptId"         , query = "{ ? = call my_pck.getEmployees(:longName)}"         , resultClass = Employee.class         , hints

  • OnPlus 100 scan, shutting down Broadcom network adapter

    I have recently installed an onPlus 100 in my network.  During the scanning process, the system seems to cause the network adapters on a few of my servers to shut down for 3-5 seconds at a time.  This was not an issue with the server either before th

  • Database Signon: Could not sign on to database PSH92DMO with user PS

    I am trying to instal peoplesoft HRMS 9.2 on Win2003(64bits) and Oracle 11g release 11.2.0.1.0 - 64bits. TUXEDO : 11.1.1.2.0 WITH VS2010 FRAMEWORK : V4.0 WEBLOGIC : 10.3.6.0 JAVA JDK 7 UPDATE 9 for Win x64 PEOPLETOOLS : 8.53 (directory c:PT8.53) vARI