SQL Query Help With Names

Jan 5, 2008

hi i have one field in employee table
where the field name is employeename
where firstname + ' ' + lastname is stored in that field
how can i break them in 2 pieces so that i can store in 2 different fields and some reacords has got
firstname+ ' ' + middlename+ ' '+ lastname and i want to store them in temp tables how can i do that.

View 1 Replies


ADVERTISEMENT

Get Table Names From Query

Mar 15, 1999

Using VB5|6/ADO/MSSQL6.5. I want to get the names of tables in a query. I.e. if query is "Select Name, Title from Employee inner join job on employee.empid = job.empid" I want a way to get "Name, Title"
In VB 3 we used the VBSQL.VBX which had 2 functions for this: SQLTabCount and SQLTabName.

Thanks in advance
DP

View 2 Replies View Related

How To Get All The Table Names By Query

Apr 5, 2008

Hi,

I have a database that have two handred tables.I want to get all the table name list.

Would you please help me if you know how to do this (query or build-in stored procedure).

Thanks

Mark

View 7 Replies View Related

Return All Databases Names Using Query?

Jun 17, 2006

Hi, I am trying to get all the databases from MS SQL into a dropdownlist. However, I am not sure how to do that in query ... is there a way to retrieve all databases name using  a query in MS SQL? Thanks.

View 1 Replies View Related

Using Variables For Table Names In Query

Mar 19, 2006

Is it possible to use variable name to dynamically define a query in a stored procedure?  EX:

@Column = 'COUNT(*)'
@Category = 'Products'
@Table = 'Items. + @Category

SELECT @Column
FROM @Table

View 1 Replies View Related

Retrieving User Names Through SQL Query

Feb 20, 2000

I am trying to retrieve the user names of all users within a database. The problem is, that I have only created a login within SQL 7.0 for the NT group that the users belong to.

As such, when I try to query the syslogins table I only get the NT group.

Is there any way of retrieving the users that belong to this NT group.

Any help or suggestions on this would be greatly appreciated.

Thanks,

Karl

View 1 Replies View Related

I Want A Query That Returns Only The Column Names

Dec 16, 2007

I want a query that returns only the column names

View 4 Replies View Related

How To Get All Field Names In A Table Using Sql Query?

Sep 11, 2006

Hi,

How canI get all field names in a table using sql query? Now I am not interested in the data in this table, what I am interested in is just the schema, i.e. all field names. Thanks.

View 22 Replies View Related

A Strange Problem With SQL Query Fro Getting Field Names

Aug 9, 2004

Hello All,

I have been trying to get this code work, but I could not. Every thing seems going well. However, The result of running the sql query is strange. It shows the field names twice.
Eg:) if you have a table called "newtable" that has two fields[Custnumber, Custname], you will get somthing like this [Custnumber, Custname Custnumber, Custname]. I have tried many times, but I couldn't fix it.



Sub Page_Load(sender As Object, e As EventArgs) handles Mybase.Load

if not page.Ispostback then

try
Sqlconnection = New Sqlconnection (connectionString)

querystring = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNs
WHERE TABLE_NAME = 'Newtable'"

SqlCommand = New SqlCommand(queryString, Sqlconnection)

SqlConnection.Open

dataReader = SqlCommand.ExecuteReader(CommandBehavior.CloseConnection)


while dataReader.Read()

Tablefields_txt.text += dataReader.Getstring(0) & ", "


End while

catch ex as Exception


msgbox("An error has occured: " + ex.Message,0, "Error Message")

finally


SqlConnection.Close()


End try
End if



Any help , please

View 3 Replies View Related

Two Different Tables, Each With Identical Column Names... Query Help

Nov 18, 2005

I have two different tables... one for all Staff, and another for all Temp Staff.  I need both to output to a datagrid, and so I need to grab both tables from a SQL query to output to my datagrid, but I can't seem to get the logic right for it to work.  Can someone give me some suggestions on why my results are blank when I'm running this query?  I thought a simple join would allow both sets of identical column names to coexist in peace...SELECT     TOP 100 PERCENT dbo.StaffDirectory.UserName, dbo.StaffDirectory.LastName, dbo.StaffDirectory.FirstName, dbo.StaffDirectory.Dept,                       dbo.StaffDirectory.Title, dbo.StaffDirectory.EMail, dbo.StaffDirectory.LocationFROM         dbo.StaffDirectory INNER JOIN                      dbo.TempStaff ON dbo.StaffDirectory.Location = dbo.TempStaff.Location AND dbo.StaffDirectory.EMail = dbo.TempStaff.Email AND                       dbo.StaffDirectory.Title = dbo.TempStaff.Title AND dbo.StaffDirectory.Dept = dbo.TempStaff.Dept AND                       dbo.StaffDirectory.FirstName = dbo.TempStaff.FName AND dbo.StaffDirectory.LastName = dbo.TempStaff.LName AND                       dbo.StaffDirectory.UserName = dbo.TempStaff.UName AND dbo.StaffDirectory.MDNo = dbo.TempStaff.MDNoIs something wrong here?  It just doesn't work =(Any suggestions would be really appreciated.Thank you

View 5 Replies View Related

How To Query Sys Tables For Index Names And Columns

Nov 12, 2001

I'm looking for a query that will return all index names, the table the index is on and the columns in the index...

View 1 Replies View Related

Query For Searching 'names' Based On First Letter

Apr 2, 2004

I would like to search MySQL table for names by selecting the first letter of the name.
eg: SELECT * FROM names WHERE lastName "begins with" M (or Mi, etc)

Right now if I use LIKE I get all names that contain "M".

Thanks.
PeterM

View 2 Replies View Related

Query Help, Get Count Of Names Having Distinct Letters

May 8, 2007

here is a query


Code:

select count(d) from (select distinct left(name,9) as d from bscs where region like 'n1' and name like 'Alc_%')



what i am trying to do is to get count of the names, having distinct letters in left 9 positions and some conditions too. How to do it?

View 5 Replies View Related

Query To Retrieve First Names Of Person Where Last Name Is John

Dec 16, 2013

I need a query which retrives the firstnames of the person where last name is john. I am considering the performance as the main factor.

Is there any better query than the following?

Select firstname from tablename where lastname='John'

Considering performance as the major factor....

View 2 Replies View Related

Query To Understand The Names Of All Available Tables In Database

Aug 31, 2014

SQL query to understand the names of all the available tables in the database , number of records in these tables and size of these tables ?

View 1 Replies View Related

Query Returning Duplicate Field Names

Jul 20, 2005

I have a .NET program that can connect to either an Access 97 database or anSQL Server 7 database. In the database I have two tables which have a fieldcalled ID. When I run a query like "SELECT A.*, B.* FROM A, B", the queryreturns those fields as "A.ID" and "B.ID" when connected to Access 97, butas "ID" and "ID" in SQL Server 7. Is there anyway to get SQL Server toprepend the table name to the field name in a case like this and not returnduplicate field names like that without having to specify aliases for thefields?- Don

View 1 Replies View Related

Dynamically Pass Table Names And File Names To IS Package

Mar 1, 2015

I am designing a package to export staging tables into a flat file.The names of the tables will be: TableAStaging_YYYYMM and TableBStaging_YYYYMM. As you can see the names of the tables will be changing each month.

The flat files will have similar naming: C:MyPathFlatFileTableAStaging__YYYYMM and C:MyPathFlatFileTableAStaging__YYYYMM.I want to run the package as an sql job in two steps, one for each table.I need to dynamically pass the table names and file names (together with the path) to the IS package.

View 1 Replies View Related

Integration Services :: Chinese Names Export To CSV - Garbled Names

Aug 11, 2015

As part if a recent requirement I have to export Chinese/Singaporean names in a CSV file. The data in the tables is a NVARCHAR(256).

I am using a FlatFile Connection manager where all the present columns from the table are exported as NVARCHARs. My understanding was that the Chinese/Singaporean names would blend seamlessly with NVARCHARs in place. But, they get garbled when pushed to the CSV.

Here is the connection manager setup

There are a lot of suggestions of fixing this by copying/pasting to a notepad file and changing the formatting... But I cant do that since the file is generated using a schedules SSIS package. How can I tweak the process to fix the issue?

View 4 Replies View Related

Retrieve All Names That Don't Have A Year (was Query To Be Written To Fetch ....)

Feb 3, 2005

Having two tables.

1. ID Year
----------
1 1990
2 1991
3 1992



2. Name Year
--------------
ABC 1
XYZ 2
123 3


By passing year as an argument, Want to retrieve all the Names that does not have records for that particular year.

For example, if pass 1990, then the result set should be 'XYZ' and '123'

Thanks in advance

View 2 Replies View Related

I Need A Query To Find Indexes Names For Some Kind Of Tables

Apr 9, 2008

Hi,
I need a query to get the index names of particular tables. for eg.. i have some tables like emp_data,emp_job....etc..Now i want to find all indexe names for those tablenames that starts with emp........ Plz help me...

View 6 Replies View Related

Query Names Of Stored Procedure Results Columns?

Mar 2, 2012

I am imagining something you might pass the names of 2 stored procs (an old version and new one), and a query to produce valid parameters. It would then fire off each proc for a set number of executions, while storing off the results in temp tables, and at the end it would do a data compare, and store off performance data from dynamic management views.

Now I know how to get the parameters for a stored procedure out of the catalogue views, but is SQL Server aware at all of the schema of the results of stored procedures that return result sets, becuase I was thinking of doing something like...

INSERT INTO #datacompare(col1,col2)
EXEC mystoredprocedure

... but I can not seem to figure out how to dynamically gather the schema of the result set.

View 1 Replies View Related

SQL Server 2012 :: Dynamic Query On DB Table Names

Mar 9, 2015

I have query which is used to dynamically insert value but not working. We are trying to get all table names and insert dynamically to all tables by looping through table names.

declare @a varchar(max),@i int;
declare @table table(rno int, name varchar(max))
declare @b varchar(max)
insert into @table
select row_number() over( order by table_name) rno, table_name from INFORMATION_SCHEMA.tables
declare @tblname varchar(max)

[Code] .....

View 1 Replies View Related

Transact SQL :: Use Dynamic Table Names And Get Return Value From The Query

Sep 16, 2015

I don't know why this is so difficult. What I want to do is take a table name as a parameter to build a query and get an integer value from the result of the query. But from all of the research I have been doing, Dynamic SQL is bad in SQL server because of SQL Injections. But my users are not going to be supplying the table names.

Things I have learned:

 - SQL Functions cannot use Exec to execute query strings.
 - SQL Functions can return a concatenated string that could be used by a stored procedure to Exec the query string.

So how can I write a stored procedure that will
 
1. take a parameter
2. Pass the parameter to a function that will return a string
3. Execute that string as SQL
4. Get a return value from that SQL statement
5. Then finally, from a View, how can I pass a parameter to the stored procedure and get the returned value from the stored procedure to be used as a field in the View?

Numbers 3, 4, and 5 are where I am really stuck. I guess I don't know the proper syntax and limitations of SQL Server.

View 14 Replies View Related

Analysis :: Show Dimension Names In MDX Query Result

Oct 28, 2015

I am facing an issue in MDX Query. I have a custom MDX query, When I run the query I am getting results too. Now my requirement is to show the dimension names in the query result, So that I can get those header names in the cell set itself. Please see the below image.

In this image I need to show 'Fiscal Year' and 'Fiscal Quarter' in that highlighted area. Is there any custom query for this?

View 3 Replies View Related

Determine Table Names And Column Names At Runtime?

Jan 22, 2004

Hi

I was wondering if anyone has an idea of how we could find the table names and column names of the tables in our Sql server database at runtime/dynamically given our connection string? Please let me know.

Thanks.

View 5 Replies View Related

Regarding The Query To Save The Ids Of The Edited Names From Different Tables Into A Single Table.

Mar 8, 2008

Here with the below query iam binding my gridview with industry name,company name,Plant Name,Group Name related to the IDs in Audit table.Select Aud.Ad_ID_PK,Aud.Audit_Name,Ind.Industry_Name,Cmp.Company_Name,Pla.Plant_Name,Gr.Groups_Name,Aud.Audit_Started_On,Aud.Audit_Scheduledto,Aud.Audit_Created_On from
Industry Ind,
Company Cmp,
Plant Pla,
Groups Gr,
Audits Audwhere Ind.Ind_Id_PK =Aud.Audit_Industry and
Cmp.Cmp_ID_PK =Aud.Audit_Company and
Pla.Pl_ID_PK =Aud.Audit_Plant and
Gr.G_ID_PK =Aud.Audit_Group and
Ad_ID_PK in (select Ad_ID_PK from Audits)
Now i want to edit these names.
when i click on edit in gridview these names will be filled into textboxes and when i change the names it should compare the name with particular tables and should get the Id of that and store in Audits table.
For example:
i have this data in my audits table:




Commercial83312

2
2
2
1
Here Commercial83312 is ID of that Audit and 2,2,2,1 are the Industry,Company,Plant and group Ids for that particular audit.In the front end i can see the names of this particular IDs.
when i edit the industry name in the UI it must check the name with industry table and get the ID of the changed name and store it in audit table.
so the data may be changed in audits table as :



Commercial83312

4
2
2
1

 




so here the industry ID is changed
I need the stored procedure for this.
please help me,its very urgent...

View 4 Replies View Related

SQL 2012 :: Query To Understand Names Of All Available Tables / Number Of Records

Aug 31, 2014

SQL query to understand the names of all the available tables , number of records in these tables and size of these tables?

View 4 Replies View Related

Variable Names Must Be Unique Within A Query Batch Or Stored Procedure.

May 4, 2007

hi ,

i got this error ... i have tried various scenarios.. nothing works for me... can any one gimme the proper guidance...



The variable name '@CCSID' has already been declared. Variable names must be unique within a query batch or stored procedure.

thanx in advance

raj

View 5 Replies View Related

SQL Server 2008 :: Query To Looking For Cases Of Period Difference In Legal Names

Jun 9, 2015

How to write a Query for multiple legal names that have the same CARE Number (same address) with difference of one Legal Name having a period in the name versus the other legal name that doesn't.

For example: Looking for cases of two of the same legal name one set off by period

All Season Equipment Ltd.
All Season Equipment Ltd

West End Housing, Inc.
West End Housing, Inc

Wellings, Norman L.
Wellings, Norman L

North Texas Boats, LLC
North Texas Boats, L.L.C.

Oktibbeha County Cooperative (A.A.L.)
Oktibbeha County Cooperative (AAL)

S & R Turf & Irrigation Equipment, L.L.C
S & R Turf & Irrigation Equipment, L.L.C.

Burke Equipment Company; Burke Equipment-Seaford, Inc.; Newark Kubota, Inc.
Burke Equipment Company
Burke Equipment-Seaford, Inc.

Pleasant Valley Outdoor Power, L.L.C.
Pleasant Valley Outdoor Power, LLC

J & D Lawn and Tractor Sales, Inc.
J&D Lawn & Tractor Sales, Inc"

View 2 Replies View Related

Query To Update Flag Column In Second Table Based On Adder Names

Sep 11, 2013

I want to update Flag column in second table based on the Adder names.

If the Applicatiion has atleast one AIX and Adder name is UDB then the flag would be True.
If the Application has more the one AIX and Adder names are diferent then the flag would be null.

APpName OS Adder

App1 ||| Windows|||Null
App1 ||| Linux |||UDB
App1 ||| AIX |||UDB
App1 ||| Linux |||Sql

App2 ||| AIX ||| UDB
App2 ||| Windows||| UDB
App2 ||| Linux ||| UDB
App2 ||| AIX ||| UDB

OUTPUT SHOULD BE LOOK LIKE BELOW

APpName OS Adder Flag

App1||| Windows|||Null|||null
App1||| Linux |||UDB |||null
App1||| AIX |||UDB |||null
App1||| Linux |||Sql |||null

App2|||AIX ||| UDB|||TRUE
App2|||Windows||| UDB|||TRUE
App2|||Linux ||| UDB|||TRUE
App2|||AIX ||| UDB|||TRUE

View 5 Replies View Related

How To Retrieve Query Results With Now Field Names, Dotted Line Or Footer

Oct 5, 2006

Hi folks,I'm trying to write a simple SELECT statement that will execute inquery analyser but will just have the data with no column names, or thedotted line between them and the data. I also want to avoid thestatement at the end which says nnn rows affected. any ideas? I want todo this because I intend to write the results to a flat file.Thanks for your helpDanny....

View 2 Replies View Related

Copy Table Column Names From SSMS Object Browser To Use In A Query

Nov 6, 2007

I thought I saw this done once before. So today I hunted around inBooks OnLine and did a Google search. So far I have found nothingclose. So if you know how to do it, please tell me or if cannot bedone, I'd appreciate know that too.Thanks in advance,IanO

View 2 Replies View Related

DB Mirroring: Different Server Names With Same Instance Names

Jan 31, 2008

I'm going to be setting up DB mirroring between two SQL Server 2005 boxes. Since these are on two different servers, can the instance names be the same? Is there any reason NOT to do so if the mirror server is going to be used exclusively for DB mirroring?

For example: if the my primary DB is located on SERVER1INSTANCE1, can the mirror be SERVER2INSTANCE1 or do the instance names have to be different even though they're on different boxes.

Thanks!

View 4 Replies View Related







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