Forum Replies Created

Viewing 15 posts - 1 through 15 (of 17 total)

  • RE: Deleting by date? Or time?

    Declare @time datetime

    Set @time = (select cast((select(left((getdate ()- 10),11))+' '+ '00:00:00.000') as smalldatetime))

    Delete from YourTable where DateColumn <= @time

  • RE: group by clause

    Of course!

    You have to put the 'group by' clause after the where condition.

    Here's one example:

    Select t, count(*) from yourtable

    where t in ('A', 'B')

    group by t

  • RE: how to clear the sql transaction log?

    You ca also add: BACKUP LOG [Yourdatabase] WITH NO_LOG

    Finally, you have:

    BACKUP LOG [Yourdatabase] WITH NO_LOG

    ALTER DATABASE [Yourdatabase] SET RECOVERY SIMPLE

    DBCC SHRINKDATABASE ( [Yourdatabase], TRUNCATEONLY )

  • RE: Formula in SQL query

    What kind of data type is income? And expense?

    If they are decimal data type, your query works.

  • RE: Packed

    I mean a data type compressed with the sign (+/-)

    In particular, I have a table (T1) in which there is a column (t) defined as text.

    The output of this query

    select...

  • RE: sql Cursor

    Hi!

    You can't assing to @var two values (col and col2).

    Try this:

    DECLARE @col (-- insert data type)

    DECLARE @col2 (--insert data type)

    DECLARE scanprofile CURSOR READ_ONLY

    FOR

    select col,col2 from sometable

    OPEN scanprofile...

  • RE: INDEXES

    Hi!

    You can use this stored procedure

    sp_helpindex [tablename]

    which gives you the index name,the index description and the index keys.

     

  • RE: Difference between char,varchar,nvarchar, nchar,varchar2

    Sorry, I posted before ending...

    For char and varchar, n must be a value from 1 through 8000.

    Does the Varchar2 exist for SQL? I know it's used by Oracle...

     

  • RE: Difference between char,varchar,nvarchar, nchar,varchar2

    The char data type is a fixed-length ANSI  character data type when the NOT NULL clause is specified. If a value shorter than the length of the column is inserted...

  • RE: Exec SP to all the database in a server

    For executing the stored procedure using a cursor, you can use this one:

    -- Var Declare

    DECLARE @name varchar(100)

    DECLARE @Database varchar(100)

    DECLARE @query nvarchar(4000)

    -- Cursor Declare

    DECLARE DB CURSOR FOR

    SELECT name

    FROM master.dbo.sysdatabases

    where name <> 'tempdb'

    and...

  • RE: To find last entered row in sybase

    I think you may also add an id column in your table using the identity function.

  • RE: Using bit flags in large tables

    I don't know how many records are flagged as active...

    What do you think about creating a view with all the records with isActive = 1 and running the queries on this view?

     

  • RE: Build inner join statement use column values?

    Sorry, my brain is very tired today

    Which is the column to join? The only possible column is the key_column, isn't it?

    In your query, which are...

  • RE: Build inner join statement use column values?

    Sorry, I can't understand...

    Would you possibly specify your needing? Can you give an example of the otuput table?

  • RE: Script to INSERT/UPDATE the same records on different DBs

    Hi!

    You can use a cursor like this one:

    DECLARE @name varchar(100)

    DECLARE @Database varchar(100)

    DECLARE @query nvarchar(4000)

    DECLARE DB CURSOR FOR

    SELECT name

    FROM master.dbo.sysdatabases

    where name not in ('tempdb', 'master', 'model', 'msdb', 'Northwind')

    order by name

    OPEN DB

    FETCH...

Viewing 15 posts - 1 through 15 (of 17 total)