Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Tuesday, March 27, 2012

getting the columns in sql server table

I want to build a page that will handle all my list table... how can i get the names of the colums in specific table if i got the table name?

Use the ColumnName property in the DataColumn object. Here's an example:

// Populate the the row with the column names

foreach (DataColumn dcin dt.Columns)

{

_ColIndex++;

oSheet.Cells[_RowIndex, _ColIndex] = dc.ColumnName;

// Bold the column headings

Excel.Range oRange = (Excel.Range)oSheet.Cells[_RowIndex, _ColIndex];

oRange.Font.Bold =true;

}

|||You could execute a query, and pull them from the SysColumns tables:
Select
SC.Name
From Syscolumns SC
inner join systypes ST on SC.xtype=ST.xtype
Where OBJECT_NAME(SC.id) = 'MyTableName'

|||Do i use the query as usaul commandtext?
because i get error massage- "invalid object name SC"|||

If you are using sql statements it is recommended that you use the schema views in the database instead of the sysobject tables directly. Here is an example that will output all of the table information for you(using the Northwind database):

declare @.tablename varchar(255)

select @.tablename = 'Employees'

SELECT INFORMATION_SCHEMA.COLUMNS.*,
(SELECT COLUMNPROPERTY(OBJECT_ID(@.tablename),
INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsComputed')) AS IsComputed,
(SELECT COL_LENGTH(@.tablename, INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME)) AS ColumnLength,
(SELECT COLUMNPROPERTY(OBJECT_ID(@.tablename), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsIdentity')) AS IsIdentity,
(SELECT COLUMNPROPERTY(OBJECT_ID(@.tablename), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsRowGuidCol')) AS IsRowGuidColumn,
(ISNULL((SELECT TOP 1 CASE INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE WHEN 'PRIMARY KEY' THEN 1 END
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS ON INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME=INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME
WHERE INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME = @.tablename AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY'), 0)) AS IsPrimaryKey,
(ISNULL((SELECT TOP 1 CASE INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE WHEN 'FOREIGN KEY' THEN 1 END
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS ON INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME=INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME
WHERE INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME=@.tablename AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'FOREIGN KEY'), 0)) AS IsForeignKey,
(ISNULL((SELECT TOP 1 CASE INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE WHEN 'UNIQUE' THEN 1 END
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS ON INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME=INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME
WHERE INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME = @.tablename
AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'UNIQUE'), 0)) AS HasUniqueConstraint
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @.tablename

|||Can you show me the code you used to execute the query? I'll check it for ya.
Thanks,
Tyler
|||this is the code:

PrivateSub settablecolumn()

Dim cmdAsNew SqlCommand()

Dim firstcolumnAsString

If oConnection.State = ConnectionState.ClosedThen oConnection.Open()

cmd.Connection = oConnection

cmd.CommandText = "Select L.Name() From Syscolumns L inner join systypes R on L.xtype=R.xtype Where OBJECT_NAME(L.id) = '" & table.SelectedItem.Value & "'"

Dim readerAs SqlDataReader = cmd.ExecuteReader

If reader.Read =TrueThen

firstcolumn = reader.Item(0)

EndIf

oConnection.Close()

EndSub
great thanks...

|||Should work if you remove the parentheses from Name:
cmd.CommandText = "Select L.Name From Syscolumns Linner join systypes R on L.xtype=R.xtype Where OBJECT_NAME(L.id) = '"& table.SelectedItem.Value & "'"
If not, let me know what the text of the Error message is.
Thanks,
Tyler

|||working great now, thank you very much.

Getting the column names

Hello,

Im trying to get the column names from a database and display them in textboxes. someone has already helped me by tellnig me that i need to use the FillSchema command. Which works just fine and I can see only the colum names in a datagrid when i bind it to that.

The problem is that I do not know how to extract the name of a column and put it in to a textbox ?

does anybody know how I can fo this ?

Thanks a million

RobExamples
This example returns column information for a specified table.

EXEC sp_columns @.table_name = 'customers'

sp_columns
Returns column information for the specified tables or views that can be queried in the current environment.

Syntax
sp_columns [ @.table_name = ] object
[ , [ @.table_owner = ] owner ]
[ , [ @.table_qualifier = ] qualifier ]
[ , [ @.column_name = ] column ]
[ , [ @.ODBCVer = ] ODBCVer ]

Arguments
[@.table_name =] object

Is the name of the table or view used to return catalog information. object_name is nvarchar(384), with no default. Wildcard pattern matching is not supported.

[@.table_owner =] owner

Is the object owner of the table or view used to return catalog information. owner is nvarchar(384), with a default of NULL. Wildcard pattern matching is not supported. If owner is not specified, the default table or view visibility rules of the underlying DBMS apply.

In Microsoft® SQL Server?, if the current user owns a table or view with the specified name, that table's columns are returned. If owner is not specified and the current user does not own a table or view with the specified object, sp_columns looks for a table or view with the specified object owned by the database owner. If one exists, that table's columns are returned.

[@.table_qualifier =] qualifier

Is the name of the table or view qualifier. qualifier is sysname, with a default of NULL. Various DBMS products support three-part naming for tables (qualifier.owner.name). In SQL Server, this column represents the database name. In some products, it represents the server name of the table's database environment.

[@.column_name =] column

Is a single column and is used when only one column of catalog information is wanted. column is nvarchar(384), with a default of NULL. If column is not specified, all columns are returned. In SQL Server, column represents the column name as listed in the syscolumns table. column can include wildcard characters using the underlying DBMS's wildcard matching patterns. For maximum interoperability, the gateway client should assume only SQL-92 standard pattern matching (the % and _ wildcard characters).

[@.ODBCVer =] ODBCVer

Is the version of ODBC being used. ODBCVer is int, with a default of 2, indicating ODBC Version 2. Valid values are 2 or 3. Refer to the ODBC SQLColumns specification for the behavior differences between versions 2 and 3.

Return Code Values
None

Result Sets
The sp_columns catalog stored procedure is equivalent to SQLColumns in ODBC. The results returned are ordered by TABLE_QUALIFIER, TABLE_OWNER, and TABLE_NAME.|||Assuming you've fill schema'd a dataSet with a table called "MyColumns" you can access the column names using the Columns collection for the datatable.


// C#
// the first column will be at index 0, the second at index 1, and so on up to dataSet.Tables["MyColumns"].Columns.Count - 1
MyTextBox0.Text = dataSet.Tables["MyColumns"].Columns[0].ColumnName

Not sure how your page is structured but you'll probably need some way to dynamically handle the number of columns returned so you can provide one textbox for each column.|||Thanks very much, both of you

It has solved my problem :)

Beers on me !!!

Friday, March 23, 2012

getting sql query in c# code

Dear All

I am a beginner and looking for some help. I have a database with just one column (some names). That is the primary key aswell. Because I want the names to be unique.

I used a grid view control to display the data and included the insert functionality in the grid view by using some code and the part of the code that does the insert is

1public static void Insert(Categories category)2 {3string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;4using (IDbConnection cn =new SqlConnection(connectionString))5 {6 cn.Open();78 IDbCommand cmd =new SqlCommand();910 cmd.CommandText ="INSERT INTO Categories (CategoryName) VALUES " +11"('" + category.CategoryName +"')";1213 cmd.Connection = cn;14 cmd.ExecuteNonQuery();15 }16 }

Question: when someone tried to enter a new name which already exists in the database it throws an error page which is what I want but is there a way to be able to display the user a message sayin g that he/she has entered a name that already exists and hence they need to try a different name? instead of the ugly error page?

Thank you in advance,

Prasad.

Yes. You need to add a Try... Catch block to catch the exception, and handle it:

public static void Insert(Categories category)
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection cn = new SqlConnection(connectionString))
{
try
{
SqlCommand cmd = new SqlCommand();

cmd.CommandText = "INSERT INTO Categories (CategoryName) VALUES (@.CategoryName)
cmd.Parameters.AddWithValue("@.CategoryName", category.CategoryName);

cmd.Connection = cn;
cn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "That value already exists. Please try another.";
}
}

I have also changed your code to use parameters, which is best practice. This means you don't have to worry about people entering words with apostrophes causing errors, or Sql Injection.

Also, you should ideally query the database to see if the name exists prior to attempting the insert. Throwing exceptions is expensive on the server.

|||

thank you. Hmm..I knew the try catch solution but I was just thinking...that the try catch would catch any exception that came from insert right?

For example if there was some other strange problem in doing the insert, it would still say "name already exists try another name!" which will be kind of strange.

lastly, Thank you for the modified code, I am a newbie and still learning, thanks for the tip! However, when I compile your code, it says

System.Data.IDataParameterCollection' does not contain a definition for 'AddWithValue'

can you please tell me how to check if that name already exists? some code would help please.

something like doing a count and on that particular name and see if count is > 1?


|||

Are you using version 1.1? If so, change that to cmd.Parameters.Add(...). AddWithValue was added to version 2.0.

Instead of hardcoding the error message, you could also use ex.Message

Label1.Text = ex.Message;

However, sometimes the error message might be too obscure for the user to understand. The most likely error will result from an attempt to insert a duplicate value. That's why I recommended that you select the value of the submitted entry first to see if it exists. If it does, abort the insert and show a message. If not, let the insert run.

|||

my mistake, I had not replaced the IDBcommand with SqlCommand

ok now coming to the second problem,

I donot know how to count the number of times the name appears in the database!

can you get me started with the code!

|||

The SQL is "Select Count(*) AS TheCount From Categories Where CategoryName = @.CategoryName"

int theCount = (int)cmd.ExecuteScalar();

Then, if theCount is more than 0, that means there is a least one row already in the database. If it doesn't exist, the value of theCount will be 0.

|||

"For example if there was some other strange problem in doing the insert, it would still say "name already exists try another name!" which will be kind of strange."

That is because you have this column as the Primary Key. The Primary Key has to be unique (ie No Duplicates)

|||

You should use a stored procedure for this kind of operations. There you can first write the code for checking for duplicate values like below.

ifexists (select 1from Categorieswhere CategoryName = @.categoryName)beginraiserror ('The provided category name already exists' , 16 , 1 )with nowaitreturnendelsebegininsert Categories (CategoryName)values (@.categoryname)end

This is just a snap of what can be included in the SP. Look at the line where raiserror function is used. You'll still have to write the SP execution code in a try catch block, but you're sure that the error stating "The provided category name already exists" is generated by your SP and all other errors are because of other problems.

For a general help regarding executing SP from code visithttp://forums.asp.net/t/1165758.aspx.

Hope this will help.

Friday, March 9, 2012

Getting Network User Names

Can you write a query to get all the network user names?
Thanks
Don
Don wrote:
> Can you write a query to get all the network user names?
> Thanks
> Don
Get's them from where? What version of SQL Server? Do you mean those
network users who are currently logged into SQL Server, or do you mean a
query of Active Directory to query all users?
For SQL 2000: You can query the master..sysprocesses table (nt_username
column) for all connected users that have connected using Windows
Authentication. Otherwise, you can use the loginname for SQL
Authentication.
For SQL 2005: You can query the sys.dm_exec_sessions dmv.
David Gugick - SQL Server MVP
Quest Software
|||If you want to get list of all the accounts, you can do this
by creating a linked server to Active Directory. See books
online topic:
OLE DB Provider for Microsoft Directory Services
The following article has more information and links:
INFO: Performing a SQL Distributed Query by Using ADSI
http://support.microsoft.com/?id=299410
-Sue
On Sun, 12 Mar 2006 08:46:02 -0800, Don
<Don@.discussions.microsoft.com> wrote:

>Can you write a query to get all the network user names?
>Thanks
>Don

Getting Network User Names

Can you write a query to get all the network user names?
Thanks
DonDon wrote:
> Can you write a query to get all the network user names?
> Thanks
> Don
Get's them from where? What version of SQL Server? Do you mean those
network users who are currently logged into SQL Server, or do you mean a
query of Active Directory to query all users?
For SQL 2000: You can query the master..sysprocesses table (nt_username
column) for all connected users that have connected using Windows
Authentication. Otherwise, you can use the loginname for SQL
Authentication.
For SQL 2005: You can query the sys.dm_exec_sessions dmv.
David Gugick - SQL Server MVP
Quest Software|||If you want to get list of all the accounts, you can do this
by creating a linked server to Active Directory. See books
online topic:
OLE DB Provider for Microsoft Directory Services
The following article has more information and links:
INFO: Performing a SQL Distributed Query by Using ADSI
http://support.microsoft.com/?id=299410
-Sue
On Sun, 12 Mar 2006 08:46:02 -0800, Don
<Don@.discussions.microsoft.com> wrote:

>Can you write a query to get all the network user names?
>Thanks
>Don

Getting Network User Names

Can you write a query to get all the network user names?
Thanks
DonDon wrote:
> Can you write a query to get all the network user names?
> Thanks
> Don
Get's them from where? What version of SQL Server? Do you mean those
network users who are currently logged into SQL Server, or do you mean a
query of Active Directory to query all users?
For SQL 2000: You can query the master..sysprocesses table (nt_username
column) for all connected users that have connected using Windows
Authentication. Otherwise, you can use the loginname for SQL
Authentication.
For SQL 2005: You can query the sys.dm_exec_sessions dmv.
David Gugick - SQL Server MVP
Quest Software|||If you want to get list of all the accounts, you can do this
by creating a linked server to Active Directory. See books
online topic:
OLE DB Provider for Microsoft Directory Services
The following article has more information and links:
INFO: Performing a SQL Distributed Query by Using ADSI
http://support.microsoft.com/?id=299410
-Sue
On Sun, 12 Mar 2006 08:46:02 -0800, Don
<Don@.discussions.microsoft.com> wrote:
>Can you write a query to get all the network user names?
>Thanks
>Don

Getting Names of Tables and Fields

Hi All,

I need to get the names of tables and fields (or atleast the fields) from a database. Is there a query I can use that will return what all the db's tables and those tables fields are?

Thanks

LeeHere is the query:


SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

SELECT INFORMATION_SCHEMA.COLUMNS.column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tableName'

Hope it helps.|||Cool, thanks. Is there an easy way to get all the foreign keys for a database?

I should have specified, SQL 2000.

Thanks

Lee|||If I remember right, you need join three information schema views to find all the foreign keys in a database, I am not aware if there is more easy to do it. If you need it I will find the query and post here.

Getting names from RID: db_id:file_id:page_no:row_no

Is there any way to retrieve table name and record data from RID:
db_id:file_id:page_no:row_no, for example,
RID: 1:1:1253:0 in my program?
Please reply me. Thanks in advance.
Regards,
Hyun-jik BaeYou may use the DBCC PAGE statement (undocumented). See:
http://www.sqlservercentral.com/col...ngdeadlocks.asp
http://www.microsoft.com/technet/pr...ks/inside6.mspx
Razvan

Wednesday, March 7, 2012

Getting list of database table names, columns, etc?

Is there a way using MS SQL Server and Enterprise Manager to get a text
document (or perhaps even a Word document) listing all table names,
column names, etc of a database?
--
Sugapablo
--
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personalNo, but you can query the system views like INFORMATION_SCHEMA.TABLES and
INFORMATION_SCHEMA.COLUMNSto get a list of all tables and their columns. You
could probably use the query from DTS to create a text document.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
What hardware is your SQL Server running on?
http://vyaskn.tripod.com/poll.htm
"Sugapablo" <russREMOVE@.sugapablo.com> wrote in message
news:vmu9gbqqkhfd84@.corp.supernews.com...
Is there a way using MS SQL Server and Enterprise Manager to get a text
document (or perhaps even a Word document) listing all table names,
column names, etc of a database?
--
Sugapablo
--
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal|||Narayana Vyas Kondreddi wrote:
> No, but you can query the system views like INFORMATION_SCHEMA.TABLES and
> INFORMATION_SCHEMA.COLUMNSto get a list of all tables and their columns. You
> could probably use the query from DTS to create a text document.
Well that sucks. :)
What I did was to dump the SQL into a .sql file (you know, listing the
CREATE TABLE commands).
Everything is there, it just looks real ugly.
I'm surprised MS SQL doesn't have this simple function, like
PostgreSQL's "/d *".
--
Sugapablo
--
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal|||Looks like you scripted the tables. But your original mail says, you wanted
to get a list of table and column names, which can be accomplished with the
following query:
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
ORDER BY TABLE_NAME, COLUMN_NAME
The results can be directly saved as a text file, from within Query
Analyzer.
What you are asking for is not really the function of a database engine.
It's more of an application thing and there are a lot of third party
database documentation tools out there. One example: fmsinc.com
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
What hardware is your SQL Server running on?
http://vyaskn.tripod.com/poll.htm
"Sugapablo" <russREMOVE@.sugapablo.com> wrote in message
news:vmubrmo29o44ca@.corp.supernews.com...
Narayana Vyas Kondreddi wrote:
> No, but you can query the system views like INFORMATION_SCHEMA.TABLES and
> INFORMATION_SCHEMA.COLUMNSto get a list of all tables and their columns.
You
> could probably use the query from DTS to create a text document.
Well that sucks. :)
What I did was to dump the SQL into a .sql file (you know, listing the
CREATE TABLE commands).
Everything is there, it just looks real ugly.
I'm surprised MS SQL doesn't have this simple function, like
PostgreSQL's "/d *".
--
Sugapablo
--
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Friday, February 24, 2012

Getting file names from path?

Hi,
Need some help here.
Is there a way to get a list of file names from the file system using T-SQL?
Or is there some other method (DTS or Setting up a linked server) which will
accomplish this? I need to provide a list of file names from a folder where
I will provide the path statement and SQL will return the file names that
exist within that particular folder. From there I can concatonate the path
with the file names then store the full path statements with file name into
a table.
Thanks in advance.
CurtYou can use sp_OA* methods to do this. Another option is to use xp_cmdshell
with a dir command like:
EXEC master..xp_cmdshell 'DIR C:\ /B'
Anith|||Hi
To add to Anith's suggestions you could write an ActiveX script in a similar
way to using the sp_OA* commands see http://www.sqldts.com/default.aspx?292
John
"Fishman" wrote:

> Hi,
> Need some help here.
> Is there a way to get a list of file names from the file system using T-SQ
L?
> Or is there some other method (DTS or Setting up a linked server) which wi
ll
> accomplish this? I need to provide a list of file names from a folder wher
e
> I will provide the path statement and SQL will return the file names that
> exist within that particular folder. From there I can concatonate the path
> with the file names then store the full path statements with file name int
o
> a table.
> Thanks in advance.
>
> Curt
>
>|||You could use a CLR TVF like so:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.IO;
using System.Collections;
public partial class UserDefinedFunctions
{
/// <summary>
/// Returns a table with one column (Name) representing all files within
the path that match the criteria.
/// </summary>
/// <param name="path">The path to search. Can be relative</param>
/// <param name="searchPattern">The wildcard search pattern. Use "*" or
null for all.</param>
/// <param name="allDirectories">Search all directories under
path.</param>
/// <param name="includeFullPath">Include the full path in the
results.</param>
/// <returns>Table</returns>
[SqlFunction(FillRowMethodName = "FillFileNameRow", TableDefinition =
"Name nvarchar(300)")]
public static IEnumerable GetFileNames(string path, string
searchPattern, bool allDirectories, bool includeFullPath)
{
if (searchPattern == null)
searchPattern = "*";
string[] files = Directory.GetFiles(path, searchPattern,
allDirectories ? SearchOption.AllDirectories :
SearchOption.TopDirectoryOnly);
if (includeFullPath == false)
{
for (int i = 0; i < files.Length; i++)
{
files[i] = Path.GetFileName(files[i]);
}
}
return files;
}
/// <summary>
/// Break the row into columns for sql.
/// </summary>
public static void FillFileNameRow(object obj, out string Name)
{
string fn = (string)obj;
Name = fn;
}
};
Usage
--
select * from dbo.GetFileNames('c:', null, 0, 1)
Name
c:\AUTOEXEC.BAT
c:\boot.ini
c:\cmds.txt
c:\CONFIG.SYS
c:\dc100a.doc
c:\desktop.ini
...
William Stacey [MVP]
"Fishman" <qwpit@.kcnet.com> wrote in message
news:OWdCp5aJGHA.1676@.TK2MSFTNGP09.phx.gbl...
| Hi,
|
| Need some help here.
| Is there a way to get a list of file names from the file system using
T-SQL?
| Or is there some other method (DTS or Setting up a linked server) which
will
| accomplish this? I need to provide a list of file names from a folder
where
| I will provide the path statement and SQL will return the file names that
| exist within that particular folder. From there I can concatonate the path
| with the file names then store the full path statements with file name
into
| a table.
|
| Thanks in advance.
|
|
| Curt
|
||||You can use the FileSystemObject to enumerate a list of files. This example
is within the context of Office VBA scripting, but the syxtax for using it
with a DTS package / VBScript Task would be very similar if not the same.
http://msdn.microsoft.com/library/d...mfilesystem.asp
"Fishman" <qwpit@.kcnet.com> wrote in message
news:OWdCp5aJGHA.1676@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Need some help here.
> Is there a way to get a list of file names from the file system using
> T-SQL?
> Or is there some other method (DTS or Setting up a linked server) which
> will
> accomplish this? I need to provide a list of file names from a folder
> where
> I will provide the path statement and SQL will return the file names that
> exist within that particular folder. From there I can concatonate the path
> with the file names then store the full path statements with file name
> into
> a table.
> Thanks in advance.
>
> Curt
>