Sunday, March 25, 2012

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
Roy>> create a table programmatically in a database.. <<
You do not do that at all. First, you write a data model of your real
world, then you implement in a schema. Your real world does not change
on the fly. If the model needs to add, alter or remove tables , you do
it with other tools, such as QA. Never in a front end program.
You might also want stop putting silly prefixes in front of data
element names (see ISO-11179).|||What do you mean "programatically?" If you mean permanently then you need
to get the Management Studio Express from
(http://msdn.microsoft.com/sql/express/)
If you mean you want to formulate a table based on some input (hopefully for
temporary usage) you just simply formulate a CREATE TABLE statement and
execute it in ADO.NET. Do you know how to execute a SQL Statement?
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:snEuf.56318$DQ4.1489316@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency), etc...
>
> TIA
> Roy
>|||What's wrong with prefixes? If you have dozens or hundreds of tables and
views, it is useful to distinguish them at a glance in stored procedure for
example.
Peter|||Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
Table prefixes are useful for segmenting code, personally, i don't use tbl_
type prefixes, but i do use vw_ because if and when I use views in code I
can quickly see that I am using a view in a query and then can more quickly
understand that there is further logic underneath that might be causing a
performance problem.
I prefix stored procedures using logical segmentation, for instance
events_sel; research_sel etc... groups objects together in the database to
make life (and development/maintanence) easier.
Tony.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>|||"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com>:
news:eGy3wlTEGHA.3200@.tk2msftngp13.phx.gbl...
> Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
> Table prefixes are useful for segmenting code, personally, i don't use
> tbl_ type prefixes, but i do use vw_ because if and when I use views in
> code I can quickly see that I am using a view in a query and then can more
> quickly understand that there is further logic underneath that might be
> causing a performance problem.
> I prefix stored procedures using logical segmentation, for instance
> events_sel; research_sel etc... groups objects together in the database to
> make life (and development/maintanence) easier.
> Tony.
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
> news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
>
This is something newer
For me KISS stands for "keep it simple, stupid"
--
Andrey Odegov
avodeGOV@.yandex.ru
(remove GOV to respond)|||Celko has strong opinions and rarely is gentle with his advice (look past
that for some good advice much of the time, but as with all advice, there
are plenty of opinions.)
Personally, I don't like any type based prefixes on anything :) I do
something like this with stored procedures, functions etc (seperated by a $
(dollar sign) like table$action or purchaseOrder$delete, or something along
these lines.
On programming objects, I don't think either way is a big deal. I don't
prefix stuff with an indication if it is a procedure or a view, etc., but
either way is fine. I do feel that prefixes on tables, views and columns
look bad because the user is often presented these names, and they don't
need to know which are tables and which are views, and a programmer can tell
based on context. And since I always look at lists of objects in the
context of what they are:
select table_schema, table_name, table_type
from information_schema.tables
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>

No comments:

Post a Comment